retrofit: Crash with UnknownHostException

Hi there, I have a crash report from Fabric. Here is the stack info:

Fatal Exception: java.net.UnknownHostException: Unable to resolve host "www.telecineplay.com.br": No address associated with hostname
       at java.net.Inet6AddressImpl.lookupHostByName + 125(Inet6AddressImpl.java:125)
       at java.net.Inet6AddressImpl.lookupAllHostAddr + 74(Inet6AddressImpl.java:74)
       at java.net.InetAddress.getAllByName + 752(InetAddress.java:752)
       at okhttp3.Dns$1.lookup + 39(Dns.java:39)
       at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress + 170(RouteSelector.java:170)
       at okhttp3.internal.connection.RouteSelector.nextProxy + 136(RouteSelector.java:136)
       at okhttp3.internal.connection.RouteSelector.next + 81(RouteSelector.java:81)
       at okhttp3.internal.connection.StreamAllocation.findConnection + 171(StreamAllocation.java:171)
       at okhttp3.internal.connection.StreamAllocation.findHealthyConnection + 121(StreamAllocation.java:121)
       at okhttp3.internal.connection.StreamAllocation.newStream + 100(StreamAllocation.java:100)
       at okhttp3.internal.connection.ConnectInterceptor.intercept + 42(ConnectInterceptor.java:42)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 92(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 67(RealInterceptorChain.java:67)
       at okhttp3.internal.cache.CacheInterceptor.intercept + 93(CacheInterceptor.java:93)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 92(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 67(RealInterceptorChain.java:67)
       at okhttp3.internal.http.BridgeInterceptor.intercept + 93(BridgeInterceptor.java:93)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 92(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept + 120(RetryAndFollowUpInterceptor.java:120)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 92(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 67(RealInterceptorChain.java:67)
       at axis.android.sdk.client.base.network.BaseUrlSelectionInterceptor.intercept + 35(BaseUrlSelectionInterceptor.java:35)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 92(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 67(RealInterceptorChain.java:67)
       at axis.android.sdk.client.base.network.AuthInterceptor.handleAuthenticatedRequest + 88(AuthInterceptor.java:88)
       at axis.android.sdk.client.base.network.AuthInterceptor.intercept + 61(AuthInterceptor.java:61)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 92(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 67(RealInterceptorChain.java:67)
       at okhttp3.logging.HttpLoggingInterceptor.intercept + 212(HttpLoggingInterceptor.java:212)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 92(RealInterceptorChain.java:92)
       at okhttp3.internal.http.RealInterceptorChain.proceed + 67(RealInterceptorChain.java:67)
       at okhttp3.RealCall.getResponseWithInterceptorChain + 179(RealCall.java:179)
       at okhttp3.RealCall.execute + 63(RealCall.java:63)
       at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute + 5(Unknown Source:5)
       at retrofit2.OkHttpCall.execute + 174(OkHttpCall.java:174)
       at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call + 40(CallExecuteOnSubscribe.java:40)
       at retrofit2.adapter.rxjava.CallExecuteOnSubscribe.call + 24(CallExecuteOnSubscribe.java:24)
       at rx.Observable.unsafeSubscribe + 10256(Observable.java:10256)
       at rx.internal.operators.OnSubscribeMap.call + 48(OnSubscribeMap.java:48)
       at rx.internal.operators.OnSubscribeMap.call + 33(OnSubscribeMap.java:33)
       at rx.internal.operators.OnSubscribeLift.call + 48(OnSubscribeLift.java:48)
       at rx.internal.operators.OnSubscribeLift.call + 30(OnSubscribeLift.java:30)
       at rx.Observable.unsafeSubscribe + 10256(Observable.java:10256)
       at rx.Completable$10.call + 588(Completable.java:588)
       at rx.Completable$10.call + 567(Completable.java:567)
       at rx.Completable.unsafeSubscribe + 2035(Completable.java:2035)
       at rx.Completable$31$1.call + 2147(Completable.java:2147)
       at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call + 230(CachedThreadScheduler.java:230)
       at rx.internal.schedulers.ScheduledAction.run + 55(ScheduledAction.java:55)
       at java.util.concurrent.Executors$RunnableAdapter.call + 428(Executors.java:428)
       at java.util.concurrent.FutureTask.run + 237(FutureTask.java:237)
       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run + 272(ScheduledThreadPoolExecutor.java:272)
       at java.util.concurrent.ThreadPoolExecutor.runWorker + 1133(ThreadPoolExecutor.java:1133)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run + 607(ThreadPoolExecutor.java:607)
       at java.lang.Thread.run + 761(Thread.java:761)

But in the source code of CallExecuteOnSubscribe, all exception should be cached, I’m really confused why the crash happened instead of calling onError(). image

Here is my dependencies:

RETROFIT_VERSION = "2.2.0"
implementation"io.reactivex:rxandroid:1.2.1",
implementation "io.reactivex:rxjava:1.3.0",
implementation "com.squareup.retrofit2:adapter-rxjava:$RETROFIT_VERSION"
implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"

Can you help pls? Thanks in advance.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

This issue still exists today. Retrofit 2.9.0 😦

This issue still exists -_-

Happens quite a lot for us. Any updates?

Yess same, I see lots of crashes reported on firebase due to unknownHostException.

Can someone confirm is it really just due to flaky or spotty internet, cuz the same API calls works sometimes disconnecting and reconnecting to wifi this issue is resolve., sometime simply after trying 2 mins later that API is working.

@JakeWharton :can you please give some advice how to handle this issue globally rather then just for a particular api call, like how we add interceptors for internet check, StethoInterceptor etc can we do something for this on global level.

This happens when you disconnecting from P2P wifi like camera wifi network. After disconnection and Android return you to your home wifi with an Internet connection, but Retforit still thinks that there is no Internet connection. Delays and retries will not help