launchdarkly / android-client-sdk

LaunchDarkly Client-side SDK for Android
Other
45 stars 23 forks source link

Errors are logged when app starts without network connections #107

Closed valeriyo closed 3 years ago

valeriyo commented 4 years ago

When my app starts without network connection (e.g. WiFi is off) - the LD library logs the following errors:

2020-09-23 22:49:28.514 11484-11560/app E/DiagnosticEventProcessor: Unhandled exception in LaunchDarkly client attempting to connect to URI: https://mobile.launchdarkly.com/mobile/events/diagnostic
    java.net.UnknownHostException: Unable to resolve host "mobile.launchdarkly.com": No address associated with hostname
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:156)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
        at java.net.InetAddress.getAllByName(InetAddress.java:1152)
        at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
        at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
        at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
        at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
        at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at com.launchdarkly.android.SSLHandshakeInterceptor.intercept(TLSUtils.java:72)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(com.google.firebase:firebase-perf@@19.0.8:5)
        at com.launchdarkly.android.DiagnosticEventProcessor.sendDiagnosticEventSync(DiagnosticEventProcessor.java:114)
        at com.launchdarkly.android.DiagnosticEventProcessor.access$300(DiagnosticEventProcessor.java:21)
        at com.launchdarkly.android.DiagnosticEventProcessor$4.run(DiagnosticEventProcessor.java:99)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
        at libcore.io.Linux.android_getaddrinfo(Native Method)
        at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
        at libcore.io.BlockGuardOs.android_getaddrinfo(BlockGuardOs.java:202)
        at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:73)
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:135)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103) 
        at java.net.InetAddress.getAllByName(InetAddress.java:1152) 
        at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49) 
        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164) 
        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129) 
        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71) 
        at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205) 
        at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106) 
        at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74) 
        at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255) 
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at com.launchdarkly.android.SSLHandshakeInterceptor.intercept(TLSUtils.java:72) 
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109) 
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201) 
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154) 
        at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(com.google.firebase:firebase-perf@@19.0.8:5) 
        at com.launchdarkly.android.DiagnosticEventProcessor.sendDiagnosticEventSync(DiagnosticEventProcessor.java:114) 
        at com.launchdarkly.android.DiagnosticEventProcessor.access$300(DiagnosticEventProcessor.java:21) 
        at com.launchdarkly.android.DiagnosticEventProcessor$4.run(DiagnosticEventProcessor.java:99) 
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462) 
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
        at java.lang.Thread.run(Thread.java:923) 
2020-09-23 22:49:28.744 11484-11560/app E/DiagnosticEventProcessor: Unhandled exception in LaunchDarkly client attempting to connect to URI: https://mobile.launchdarkly.com/mobile/events/diagnostic
    java.net.UnknownHostException: Unable to resolve host "mobile.launchdarkly.com": No address associated with hostname
        at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:124)
        at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:103)
        at java.net.InetAddress.getAllByName(InetAddress.java:1152)
        at okhttp3.Dns$Companion$DnsSystem.lookup(Dns.kt:49)
        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
        at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
        at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
        at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
        at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at com.launchdarkly.android.SSLHandshakeInterceptor.intercept(TLSUtils.java:72)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
        at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(com.google.firebase:firebase-perf@@19.0.8:5)
        at com.launchdarkly.android.DiagnosticEventProcessor.sendDiagnosticEventSync(DiagnosticEventProcessor.java:114)
        at com.launchdarkly.android.DiagnosticEventProcessor.access$300(DiagnosticEventProcessor.java:21)
        at com.launchdarkly.android.DiagnosticEventProcessor$4.run(DiagnosticEventProcessor.java:99)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:923)

It's understandable that the library would try to connect to the mothership and that would fail - but treating these failures as ERRORS is not right. This spams the logs for no good reason.

Please, maybe consider, logging these as Warnings? Ideally, you wouldn't even try to connect if there is no internet connectivity. Thanks.

gwhelanLD commented 4 years ago

Hi @valeriyo,

Thanks for the report, you're absolutely correct in these points. I've filed them internally (ch90774) to be addressed when we get the chance. We have logic elsewhere in the SDK for avoiding calls when the network is known to be unavailable, but apparently we missed handling that for this feature. We'll adapt that, as well as update the logging level for this message if a request fails when the network is not known to be unavailable.

Thanks! @gwhelanLD

gwhelanLD commented 3 years ago

Thanks again for pointing this issue out, it should now be fixed in the 3.0.0 release. The SDK will avoid network calls for diagnostics when the network is known to be unavailable, and if there is an exception here regardless it will no longer be logged at an error level. This should bring the behavior of this functionality in line with the other network behavior of the SDK.

Thanks, @gwhelanLD

tariana commented 3 years ago

Hi @gwhelanLD, I noticed this issue is still happening after updating to 3.0.0 version. Could you please consider taking a look at it again? Thanks!

gwhelanLD commented 3 years ago

Hi @tariana,

I think I see what you're talking about. Our fix did address the error level log messages as well as these messages being repeated on the diagnostic reporting interval, but we're still getting an initial warning message (or two) if started without an internet connection. That's still non-ideal when the SDK should be aware of the network unavailability, so we'll definitely see about addressing this. I believe I should be able to get a fix in with the next patch release that should be coming soon.

Thanks for letting us know, @gwhelanLD

mateusz-nawrot commented 2 years ago

Hi @gwhelanLD , we are still observing a lot of Exceptions thrown on version 3.0.2. Do you have any updates on the fix?

jonathanshim commented 11 months ago

Hi, any update on this? It still happens a lot on version 4.2.3.