okhttp: NoSuchElementException in RouteSelector
okhttp 3.7.0 retrofit 2.2.0
All device brands and Android versions are reporting this issue.
It happened for example after I tapped a notification, the app then makes a GET which ended in this exception. It didn’t happen when I recreated the scenario. Device was Pixel, Android 7.1.2, on WLAN.
java.util.NoSuchElementException
at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:77)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:171)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:211)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at com.readystatesoftware.chuck.ChuckInterceptor.intercept(ChuckInterceptor.java:167)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at com.myownpackage.manager.OkHttpManager$AuthenticationInterceptor.intercept(OkHttpManager.java:135)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at com.myownpackage.manager.OkHttpManager$NetworkLoggingInterceptor.intercept(OkHttpManager.java:190)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall.execute(RealCall.java:69)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:89)
at com.myownpackage.ui.ProfileFragment$11.doInBackground(ProfileFragment.java:516)
at com.myownpackage.ui.ProfileFragment$11.doInBackground(ProfileFragment.java:511)
at com.nanotasks.AbstractTask.doInBackground(AbstractTask.java:18)
at com.nanotasks.AbstractTask.doInBackground(AbstractTask.java:7)
at android.os.AsyncTask$2.call(AsyncTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 14
- Comments: 65 (14 by maintainers)
Commits related to this issue
- Recover from a stale coalesced connection. https://github.com/square/okhttp/issues/3308 — committed to square/okhttp by dave-r12 7 years ago
- Recover from a stale coalesced connection. https://github.com/square/okhttp/issues/3308 — committed to square/okhttp by dave-r12 7 years ago
- Prepare to release OkHttp 3.8.1. It has a fix for https://github.com/square/okhttp/issues/3308 — committed to square/okhttp by swankjesse 7 years ago
- Update okhttp version from 3.8.0 to 3.9.0. This update is said to fix the issue: https://fabric.io/rocketchat3/android/apps/chat.rocket.android/issues/59aabd5fbe077a4dcc019902 as refereced by: https:/... — committed to RocketChat/Rocket.Chat.Android by leonardoaramaki 7 years ago
- Recover from a coalesced connection that immediately goes unhealthy. https://github.com/square/okhttp/issues/3308 — committed to square/okhttp by dave-r12 5 years ago
- Add test for connection that goes immediately unhealthy. https://github.com/square/okhttp/issues/3308 — committed to square/okhttp by dave-r12 4 years ago
- Give up when ExchangeFinder exhausts all routes. https://github.com/square/okhttp/issues/3308 — committed to square/okhttp by dave-r12 4 years ago
Fix released as OkHttp 3.8.1.
version 3.14.2
I got the same issue with okhttp = “4.9.0” and retrofit = “2.9.0”
Fatal Exception: java.util.NoSuchElementException at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:63) at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:205) at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:106) at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.java:74) at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.java:255) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:32) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:95) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:83) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:76) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at com.sephora.framework.api.webservice.dotcom.akamaibot.AkamaiBotInterceptor.intercept(AkamaiBotInterceptor.java:9) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at com.sephora.framework.firebase.CrashlyticsInterceptor.intercept(CrashlyticsInterceptor.java:23) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at com.sephora.framework.api.webservice.dotcom.request.interceptor.behaviour.BehaviourInterceptor.intercept(BehaviourInterceptor.java:39) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at com.sephora.framework.api.webservice.dotcom.request.interceptor.AddUserAgentInterceptor.intercept(AddUserAgentInterceptor.java:23) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at com.sephora.framework.api.webservice.dotcom.request.interceptor.AddCustomHeadersInterceptor.intercept(AddCustomHeadersInterceptor.java:17) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:109) at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.java:201) at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.java:517) 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)
Haven’t seen this crash for some time now. Great Job 👍
Thanks @dave-r12. It turns out to be the case, somehow build was not pulling 3.9.0. I will provide feedback after testing with 3.9.0. Thank you once again.
Fixed in OkHttp 3.12.
java.util.NoSuchElementException at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:78) at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:171) at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:135) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) at java.lang.Thread.run(Thread.java:856)
@swankjesse I think because I save it to the array and clear ( cancelAll () ) the whole array when I exit the screen.
Bad news, guys. I’ve just got this crash on okhttp v4.4.0 (on Android).
If you could help to reproduce it, that’s the first step.