Samsung S8/8+ SocketTimeoutException SSL handshake timed out
See original GitHub issueHello guys, we started to get a bulk increase in SocketTimeoutException SSL handshake timed out for S8 and S8+ phones.
Versions used: `okhttp3 : ‘3.9.0’
retrofit : ‘2.3.0’,
Samsung models: SM-G950F SM-G955F
Android version: 7.0 Kernel version 4.4.13-12401979 ` I tried creating a sample project that would try to fetch anything from any server to reproduce and politely report the issue but no avail, I cannot reproduce it steadily.
I am unsure but I have a feeling this happens when switching between Mobile network / Wifi or the device comes from sleep, after 2-3 attempts the connection punches trough.
Other phones / our health checks do not report this issue on other devices, or they are really minimal, samsung s8 / s8+ cover over 70% of the issues (and we have quite big userbase).
Do you have any hints for me how can I assist in creating a better error report or advices how to diagnose what is wrong and how to fix it.
Code that we use to setup okhttp client:
builder.followSslRedirects(true);
builder.followRedirects(true);
builder.connectTimeout(90, TimeUnit.SECONDS);
builder.readTimeout(90, TimeUnit.SECONDS);
builder.writeTimeout(90, TimeUnit.SECONDS);
builder.retryOnConnectionFailure(false);
builder.cache((new Cache(app.getDir(CACHE_DIR, Context.MODE_PRIVATE), CACHE_SIZE))
builder.interceptors().add(chain -> {
if
(!chain.request().url().host().equals(URI.create(current.companyName().getUrl()).getHost()))
{
return chain.proceed(chain.request());
}
Request.Builder builderChain = chain.request().newBuilder();
builderChain.addHeader(AUTHORIZATION, credential);
return chain.proceed(builderChain.build());
});
Request.Builder builderChain = chain.request().newBuilder();
builderChain.header(USER_AGENT, USER_AGENT_VALUE);
return chain.proceed(builderChain.build());
builder.connectionPool(new ConnectionPool(5, 5, TimeUnit.MINUTES));
Caused by: java.net.SocketTimeoutException: SSL handshake timed out at
com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) at
com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:364) at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:299) at
HTTP request failure at io.reactivex.internal.operators.observable.ObservableSingleSingle$SingleElementObserver.onError(ObservableSingleSingle.java:95) at
retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:55) at io.reactivex.Observable.subscribe(Observable.java:10903) at
io.reactivex.internal.operators.observable.ObservableSingleSingle.b(ObservableSingleSingle.java:35) at io.reactivex.Single.a(Single.java:2700) at
io.reactivex.internal.operators.single.SingleLift.b(SingleLift.java:44) at io.reactivex.Single.a(Single.java:2700) at
io.reactivex.internal.operators.single.SingleLift.b(SingleLift.java:44) at io.reactivex.Single.a(Single.java:2700) at
io.reactivex.internal.operators.single.SingleSubscribeOn$SubscribeOnObserver.run(SingleSubscribeOn.java:89) at io.reactivex.Scheduler$DisposeTask.run(Scheduler.java:452) at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:61) at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:52) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:272) 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:762) Caused by: java.net.SocketTimeoutException: SSL handshake timed out at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) at
com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:364) at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:299) at
okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:268) at
okhttp3.internal.connection.RealConnection.connect(RealConnection.java:160) at
okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:256) at
okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:134) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:113) at
okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at
okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at
okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at
okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:125) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at
de.app.core.data.network.api.ApiModule$$Lambda$0.intercept(Unknown Source) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at
okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:143) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at
de.app.core.data.network.api.ApiModule$$Lambda$2.intercept(Unknown Source) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at
okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at
okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) at
okhttp3.RealCall.execute(RealCall.java:77) at retrofit2.OkHttpCall.execute(OkHttpCall.java:180) at
retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:41) ... 16 mor
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Top GitHub Comments
I cannot put my finger on it but this happens somewhere inbetween switching from mobile data to Wifi, mostly on Wifi, could it be that connection pool somehow gets crazy but tbh I think this is vendor specific
I had a very similar problem with my app on Samsung S8 https://stackoverflow.com/questions/57701810/failed-to-connect-when-device-is-disconnected-from-pc/57734913#57734913
Turned out I had battery saving option Restrict background data enabled and that prevented my app from reaching the internet. I experienced both
failed to connect
andSSL handshake timeout
errors and they are gone once I disabled this option.