bug retrofit.RetrofitError: java.io.EOFException for Android
10,702
Solution 1
I finally resolve the problem. Like mromer said, the solution was to use both OkClient and OkHttp. After adding these two libraries I set the client on Retrofit to OkHttp like that:
RestAdapter restAdapter = new RestAdapter.Builder()
.setErrorHandler(new ErrorRetrofitHandlerException())
.setEndpoint(urlBase)
.setLogLevel(RestAdapter.LogLevel.FULL)
.setClient(new OkClient(new OkHttpClient()))
.build();
Solution 2
This is a known issue:
https://github.com/square/retrofit/issues/397
Did you try using OkHttp?
Author by
tamtoum1987
Updated on June 13, 2022Comments
-
tamtoum1987 almost 2 years
I search a lot, I found some solutions like this:
System.setProperty("http.keepAlive", "false"); arg0.addHeader("Connection", "close"); arg0.addHeader("Accept-Language", "en-US,en;q=0.8");
I try them but didn't work for me. How can I correct this bug? Here is my log:
D/Retrofit(28969): ---> HTTP POST http://release.api.jeunesse.build.indus.ftven.net/app.php/api/users D/Retrofit(28969): Connection: close D/Retrofit(28969): Content-Type: application/json D/Retrofit(28969): Content-Length: 169 D/Retrofit(28969): {"birthday":"2010-06-05T12:16:42+0200", \ "devices":[{"device":"ae045e7bead6f933487a237f8b5f298d","primary":true}],\ "email":"[email protected]","login":"test9","password":"9876"} D/Retrofit(28969): ---> END HTTP (169-byte body) D/Retrofit(28969): ---- ERROR http://release.api.jeunesse.build.indus.ftven.net/app.php/api/users D/Retrofit(28969): java.io.EOFException D/Retrofit(28969): at libcore.io.Streams.readAsciiLine(Streams.java:203) D/Retrofit(28969): at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:579) D/Retrofit(28969): at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:827) D/Retrofit(28969): at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:283) D/Retrofit(28969): at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497) D/Retrofit(28969): at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73) D/Retrofit(28969): at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38) D/Retrofit(28969): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321) D/Retrofit(28969): at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240) D/Retrofit(28969): at $Proxy3.createUser(Native Method) D/Retrofit(28969): at fr.francetv.ludo.backend.services.businessdelegate .RetrieveFluxDonneesBDL.postInscription(RetrieveFluxDonneesBDL.java:323) D/Retrofit(28969): at fr.francetv.ludo.backend.services.metier.user .AdministrerUser.inscriptionUser(AdministrerUser.java:202) D/Retrofit(28969): at fr.francetv.ludo.backend.services.metier .AdministrerHelper.inscriptionUser(AdministrerHelper.java:158) D/Retrofit(28969): at fr.francetv.ludo.ui.inscription .InscriptionLoginFragment$3.background(InscriptionLoginFragment.java:136) D/Retrofit(28969): at fr.francetv.ludo.ui.inscription .InscriptionLoginFragment$3.background(InscriptionLoginFragment.java:1) D/Retrofit(28969): at fr.francetv.ludo.backend.services.AsyncHelper.doInBackground(AsyncHelper.java:28) D/Retrofit(28969): at fr.francetv.ludo.backend.services.AsyncHelper.doInBackground(AsyncHelper.java:1) D/Retrofit(28969): at android.os.AsyncTask$2.call(AsyncTask.java:287) D/Retrofit(28969): at java.util.concurrent.FutureTask.run(FutureTask.java:234) D/Retrofit(28969): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) D/Retrofit(28969): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) D/Retrofit(28969): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) D/Retrofit(28969): at java.lang.Thread.run(Thread.java:841) D/Retrofit(28969): ---- END ERROR
Thanks for your responses
-
tamtoum1987 almost 10 yearsI try this i have this error now 07-18 15:05:34.598: E/AsyncHelper(13832): Exception caught: Retrofit detected an unsupported OkHttp on the classpath. i use <dependency> <groupId>com.squareup.okhttp</groupId> <artifactId>okhttp</artifactId> <version>2.0.0</version> </dependency>
-
lazypig over 9 yearsI tried this but I still get this.I believe the problem comes from a connection problem from the device not having a good connection or the server not accepting the connection and so just errors out not getting a response.
-
Aurasphere almost 8 yearsSame problem here. The error is not consistent for me.