instacart / truetime-android

Android NTP time library. Get the true current time impervious to device clock time changes
https://tech.instacart.com/truetime/
Apache License 2.0
1.41k stars 194 forks source link

untrusted stratum value for TrueTime: 0 ? #125

Open ZimM-LostPolygon opened 4 years ago

ZimM-LostPolygon commented 4 years ago

No idea what triggers it, but occasionally, TrueTimeRx fails to initialize with a untrusted stratum value for TrueTime: 0. I am using the pool.ntp.org pool.

After a few hours, the issue just goes away, but it's usually back soon enough. Looking at the logs, my guess about what happens is that TrueTimeRx only does requests to a single server (193.70.94.182 in this case) again and again, even though it is misbehaving. Perhaps it would be better to retry with a different server instead of wasting all attempts on a single one?

Code I use:

mTrueTime =
    TrueTimeRx
        .build()
        .withLoggingEnabled(true)
        .withConnectionTimeout(15 * 1000)
        .withServerResponseDelayMax(1000)
        .withRootDispersionMax(1500)
        .withRootDelayMax(1500)
        .withSharedPreferencesCache(context);
mTrueTime
    .initializeRx("pool.ntp.org")
    .subscribeOn(Schedulers.io())
    .subscribe(...)

Full log: log.txt

mice777 commented 1 year ago

Another source indicates that value 0 is valid (= Unspecified or Unavailable)