6

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":"test@test.fr","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

JJD
  • 50,076
  • 60
  • 203
  • 339
tamtoum1987
  • 1,957
  • 3
  • 27
  • 56

3 Answers3

5

This is a known issue:

https://github.com/square/retrofit/issues/397

Did you try using OkHttp?

mromer
  • 1,867
  • 1
  • 13
  • 18
  • I 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 com.squareup.okhttp okhttp 2.0.0 – tamtoum1987 Jul 18 '14 at 13:08
3

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();
JJD
  • 50,076
  • 60
  • 203
  • 339
tamtoum1987
  • 1,957
  • 3
  • 27
  • 56
  • 1
    I 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. – lazypig Dec 11 '14 at 01:57
  • Same problem here. The error is not consistent for me. – Aurasphere Jul 23 '16 at 17:23
0

Check your internet connection, use a real device and test the app

Ali Hasan
  • 653
  • 9
  • 8