truetime-android: Causes ANR and SocketTimeoutException on emulators

Simply running the RxTrueTime sample2 on an Android emulator causes java.net.SocketTimeoutException Poll timed out. It’s even causing ANR’s inside my own project (also on emulators).

Tried this on 2 separate environments running emulators with different Android versions, they all show the same problem.

Everything works fine on my real devices.

Is this expected behavior and can I ignore this or should this actually work?

Logs:


09-19 16:44:26.899 20496-21765/com.instacart.library.truetime D/TrueTimeRx: ---- resolving ntpHost : time.google.com
09-19 16:44:26.901 20496-21768/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 216.239.35.8
09-19 16:44:26.901 20496-21769/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 216.239.35.8
09-19 16:44:26.901 20496-21770/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 216.239.35.8
09-19 16:44:26.902 20496-21771/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 216.239.35.8
09-19 16:44:26.902 20496-21772/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 216.239.35.8
09-19 16:44:26.902 20496-21773/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 2001:4860:4806:8::
09-19 16:44:26.903 20496-21774/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 2001:4860:4806:8::
09-19 16:44:26.903 20496-21775/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 2001:4860:4806:8::
09-19 16:44:26.903 20496-21776/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 2001:4860:4806:8::
09-19 16:44:26.903 20496-21777/com.instacart.library.truetime D/TrueTimeRx: ---- requestTime from: 2001:4860:4806:8::

Logs don’t continue after that, it just loops forever and showing the SocketTimeoutException + causing the ANR.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 22

Most upvoted comments

Hi, maybe it’s not related to this issue particularly, but there is a bug in TrueTime that causes ANRs on every device. The problem is with synchronized methods in SntpCient (886acc1b683e74569e6d96e8d94ab9e9a4f71e5d). Every time you try to call TrueTime.isInitialized() or TrueTime.now() on the main thread, it’s blocked by requestTime(). It’s a serious issue when the NTP server lags or don’t even respond.

We have switched to https://github.com/AllanHasegawa/Tempo which, for now at least, has not given any of the issues we’ve had with truetime.

Like @chris6647 we have switched to Tempo…

@kaushikgopal LGTM, finally merged. I have already implemented it on my project. Thanks.

master should have the required fixes now. If you’re eager to take this before it hits 3.4 try:

implementation com.github.instacart.truetime-android:library-extension-rx:09087b6a6e

We have switched to https://github.com/AllanHasegawa/Tempo which, for now at least, has not given any of the issues we’ve had with truetime.

@fecogc As per jitpack documentation - https://github.com/jitpack/jitpack.io/blob/master/FAQ.md We can use 'com.github.instacart.truetime-android:library-extension-rx:kg~fix~sync_to_atomic-SNAPSHOT' to get that branch compiled.

Hi @kaushikgopal I wasn’t able to get the branch from jitpack… Is this the correct brach name?

https://jitpack.io/#instacart/truetime-android/kg~fix/sync_to_atomic-SNAPSHOT

compile ‘com.github.instacart.truetime-android:library-extension-rx:kg~fix’

@jksiezni @lemberh - i have an branch “sync_to_atomic” that should address that issue. I’m giving it a run in production internally before merging it to make sure it has an effect. it’s looking promising so far.

feel free to give that a shot (you can point directly to the commit via jitpack).

i’ll have that branch merged as soon as i gain some real world data. 🤞