7

We have an existing Android app that uses Retrofit to connect to a server and send and receive JSON. Since updating my device to Android 4.4.4 I am getting the following error when trying to connect:

D/Retrofit(8004): javax.net.ssl.SSLException: Read error: ssl=0x768c5c40: I/O error during system call, Connection reset by peer
D/Retrofit(8004):  at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
D/Retrofit(8004):  at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:689)
D/Retrofit(8004):  at okio.Okio$2.read(Okio.java:136)
D/Retrofit(8004):  at okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
D/Retrofit(8004):  at okio.RealBufferedSource.indexOf(RealBufferedSource.java:244)
D/Retrofit(8004):  at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:191)
D/Retrofit(8004):  at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:189)
D/Retrofit(8004):  at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101)
D/Retrofit(8004):  at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:676)
D/Retrofit(8004):  at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:426)
D/Retrofit(8004):  at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:371)
D/Retrofit(8004):  at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:466)
D/Retrofit(8004):  at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
D/Retrofit(8004):  at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
D/Retrofit(8004):  at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
D/Retrofit(8004):  at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
D/Retrofit(8004):  at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
D/Retrofit(8004):  at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
D/Retrofit(8004):  at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
D/Retrofit(8004):  at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
D/Retrofit(8004):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
D/Retrofit(8004):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
D/Retrofit(8004):  at retrofit.Platform$Android$2$1.run(Platform.java:142)
D/Retrofit(8004):  at java.lang.Thread.run(Thread.java:841)

I've updated to the latest versions of Retrofit / OkHTTP and Okio but the error persists. I'm guessing this has to do with the OpenSSL patch that was part of Android 4.4.4 but I can not find a solution to this error.

Has anyone else come across this and, if so, found a fix?

Thanks

Rich

Lucas Prestes
  • 362
  • 1
  • 4
  • 19
Rich Morey
  • 343
  • 2
  • 11
  • Similar issue - http://stackoverflow.com/questions/30538640/javax-net-ssl-sslexception-read-error-ssl-0x9524b800-i-o-error-during-system – Rickster Jun 08 '15 at 18:14

1 Answers1

0

For use Retrofit in Pre-lollipop Android you should use lower version of OKhttp and forced to implementation a specific version that support on Pre-lollipop

implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation ("com.squareup.okhttp3:okhttp:3.12.12"){
    force = true //API 19 support
}
Shahab Saalami
  • 862
  • 10
  • 18