square / retrofit

A type-safe HTTP client for Android and the JVM
https://square.github.io/retrofit/
Apache License 2.0
42.96k stars 7.3k forks source link

1.4.0 New line in String causes retrofit.RetrofitError: java.io.EOFException #397

Closed mazurio closed 10 years ago

mazurio commented 10 years ago

Gist: https://gist.github.com/mazurio/8750846

Description is a text taken from TextView (Android), if it contains more than one new line then it causes EOFException and insert fails. Trying to figure it out now.

I tried to escape the string. It is the same problem.

mazurio commented 10 years ago

I have found out what causes the problem, this is ANDROID AOSP bug. More here:

http://stackoverflow.com/questions/19258518/android-httpurlconnection-eofexception http://stackoverflow.com/questions/15411213/android-httpsurlconnection-eofexception http://stackoverflow.com/questions/12319194/android-httpurlconnection-throwing-eofexception

I am not really sure how it should be "fixed" in RetroFit. It was already fixed in AOSP but the bug is still there in older versions.

JakeWharton commented 10 years ago

Are you saying that one of the fields in the Announcement instance contains a newline which causes the request to throw the EOFException? Can you tell me what version of Android you are seeing this on, whether or not you are using OkHttp, and if you are using the default serialization or supplying a custom Converter?

mazurio commented 10 years ago

Hi Jake,

Yes indeed, one of the fields in the Announcement or basically any String causes that. I tried both 4.1 and 4.4.2 KitKat. I am using default serialization. I am not so sure if I am using any OkHttp.

Also: it's random, sometimes it works, sometimes it doesn't even with the same data.

JakeWharton commented 10 years ago

Thanks I'll try to repro soon. If you are able to turn on logging (setLogging(FULL)) and capture the full request body that'd also help.

swanson commented 10 years ago

I tested this out in my app. API 18, Retrofit 1.4.1, OkHttp 1.3.0 - and everything seems to be okay when POSTing fields with multiple new lines, though, as you mention, it is intermittent so it's possible I just haven't hit it.

The request body looked something like this (some data redacted, sorry):

02-07 13:21:31.562: D/Retrofit(2445): ---> HTTP POST http://localhost:8080/Api/Mailbox/Message
02-07 13:21:31.562: D/Retrofit(2445): Content-Type: application/json; charset=UTF-8
02-07 13:21:31.562: D/Retrofit(2445): Content-Length: 135
02-07 13:21:31.562: D/Retrofit(2445): {"Body":"Test with multiple newlines\n\n\nAsdf\n\n\nAsdf\n\n\n\n\n\n\nAsdfasdf","Subject":"Test","To":3}
02-07 13:21:31.562: D/Retrofit(2445): ---> END HTTP (135-byte body)
artworkad commented 10 years ago

retrofit 1.4.1, I noticed the same exception. I tested on nexus 4 with android 4.4.2, no issues. Then I tested on samsung galaxy s3 mini with android 4.1.9 and got the eof exception (only for post requests). This happens randomly, but must of the time.

Further I noticed, that I have to retry the async call when getting this exception. On second try it will do the rest call.

03-11 19:56:37.445    8476-8476/d.. W/System.err﹕ retrofit.RetrofitError: java.io.EOFException
03-11 19:56:37.445    8476-8476/d.. W/System.err﹕ at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:420)
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:262)
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:313)
03-11 19:56:37.455    8476-8476/d.. W/System.err﹕ at retrofit.CallbackRunnable.run(CallbackRunnable.java:38)
03-11 19:56:37.455    8476-8476/d.. W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ at retrofit.Platform$Android$2$1.run(Platform.java:136)
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ at java.lang.Thread.run(Thread.java:856)
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ Caused by: java.io.EOFException
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ at libcore.io.Streams.readAsciiLine(Streams.java:203)
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:560)
03-11 19:56:37.455    8476-8476/d... W/System.err﹕ at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:813)
03-11 19:56:37.465    8476-8476/d... W/System.err﹕ at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
03-11 19:56:37.465    8476-8476/d... W/System.err﹕ at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486)
03-11 19:56:37.465    8476-8476/d... W/System.err﹕ at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:94)
03-11 19:56:37.465    8476-8476/d.... W/System.err﹕ at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:49)
03-11 19:56:37.465    8476-8476/d... W/System.err﹕ at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:357)
03-11 19:56:37.465    8476-8476/d...W/System.err﹕ ... 7 more

:+1: for a fix @JakeWharton

My dirty fix:

@Override
public void failure(RetrofitError error) {
    if(error.toString().contains("java.io.EOFException")){
        doAgain();
    }else{
       handleFailure();
   }
}
jeffdcamp commented 10 years ago

I'm also seeing this same issue randomly (on POST requests). I never see this on a device running Android 4.4.2 (including Nexus and Galaxy S4), but I'm seeing this on several devices running Android 4.3 or less (including the Android 4.3 Emulator).

It seems that if I do back-to-back calls (using the very same call), that we see this issue happen. It actually appears that it happens on every-other call (the first call succeeds, the next call throws an EOFException, then the next call succeeds, repeat). I'm assuming that something is getting reset after the Exception.

Update: I'm seeing this with only POST and PUT back-to-back calls that contain @Body.

Should I be resetting something with retrofit between calls?

FYI... The only work around is to watch for the "EOFException" and the retry (EOFException happens on every other call)

gwvatieri commented 10 years ago

@jeffdcamp @ArtworkAD do you have update for this? Having same problem, it happens often but randomly.

artworkad commented 10 years ago

@gwvatieri check for exception and retry, this is the only fix at the moment

@Override
public void failure(RetrofitError error) {
    if(error.toString().contains("java.io.EOFException")){
        doAgain();
    }else{
       handleFailure();
   }
}
ansgarm commented 10 years ago

Or include and use OkHttp. That worked for me if I remember correctly.

gwvatieri commented 10 years ago

I have seen that @ArtworkAD, I'll give it a try, thanks. @ansgarm was OkHttp used by default when present?

ansgarm commented 10 years ago

Yes, it is. Simply adding it to my gradle build files solved the problem for me.

gwvatieri commented 10 years ago

@ansgarm I'll include it and try. Can't reproduce it systematically so not sure how to test it.

jeffdcamp commented 10 years ago

My only work-around is to retry (just like what @ArtworkAD mentioned) (kinda painful to put that everywhere)

gwvatieri commented 10 years ago

Hey @jeffdcamp have you tried to include OKHttp? @ansgarm problem with cache after using it?

theblang commented 10 years ago

I experienced this issue on a Nexus 5 running 4.3. It would seem to occur after some time had passed since the last request. It would always work the second time and it only seemed to occur with POST requests. @gwvatieri I switched over to OKHttp and wow, my requests were about fifty percent faster. I didn't see this issue anymore after switching. I just .setClient(new OKClient()) when building the RestAdapter.

gwvatieri commented 10 years ago

Hey @mattblang you don't need to set it manually, it's done automatically, you just need to include the library in your classpath. I did it and it looks like the issue is no longer happening, I'll confirm it later.

https://github.com/square/retrofit/blob/f181d1c2b923ed04683bc4b91baf15cdb310a928/retrofit/src/main/java/retrofit/Platform.java#L74

kaciula commented 10 years ago

For me, it's still happening with the okhttp library included in the dependencies. (Nexus 4, Android 4.4)

jeffdcamp commented 10 years ago

I finally got around to a situation that I was reproducing this error on every-other-call and I finally added the following to my project:

compile 'com.squareup.okhttp:okhttp:1.5.4'

By doing so, it seems to help quite a bit with this issue (I don't hardly ever see the same error when doing a POST now).

theDazzler commented 10 years ago

I also am getting this error when issuing a POST request with String data from a multitext EditText in Android. it occurs every time for me, not every other time.

JakeWharton commented 10 years ago

Still can't repro. Seeing an actual request body that causes this would help greatly.

jeffdcamp commented 10 years ago

For us.... this only happens with the following:

as stated before.... our work-around to this issue is to simply depend on okhttp:1.5.4.

pflammertsma commented 10 years ago

It appears that this problem has disappeared with Retrofit 1.6.x. Is anybody still experiencing this?

marcelpinto commented 10 years ago

I just get it with 1.6.1

Caused by: java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203) at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:560) at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:813) at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274) at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486) at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)

hrafnthor commented 10 years ago

Currently using Retrofit 1.6.0 and getting a EOFException intermittently while doing POST. Not using OKHttp, running on Android 4.2.2 when it happens.

roman-mazur commented 10 years ago

I believe the reason is in Android URLConnection implementation. It's not Retrofit fault. I remember this happening after changing HTTP method. I mean a sequence of requests GET, POST, GET, POST.

JakeWharton commented 10 years ago

Can someone that reliably reproduces this try with OkHttp 2.0?

jeffdcamp commented 10 years ago

I use to see this issue all of the time till included OkHttp into my project (using either 1.5.x, 1.6.x, or 2.0.x resolved this issue for me).

theblang commented 10 years ago

I also never saw this again after including OkHttp 1.5.x, nor since updating OkHttp to 2.0.0-RC2.

JakeWharton commented 10 years ago

Ok. Deeming this a platform bug without a suitable workaround. Recommended fix is to use OkHttp.

hongzhou85 commented 10 years ago

Is this issue fixed? I'm using OkHttp with Retrofit but I'm still seeing this issue of EOF happening too often. I'm using this in an PageView Adapter on Android and it makes multiple calls together to fetch data. The performance is very bad, it takes many retries to get a success request. Has this got to do with reusing of connection?

08-10 10:42:05.964: D/Retrofit(11501): java.io.EOFException 08-10 10:42:05.964: D/Retrofit(11501): at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:192) 08-10 10:42:05.964: D/Retrofit(11501): at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:189) 08-10 10:42:05.964: D/Retrofit(11501): at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101) 08-10 10:42:05.964: D/Retrofit(11501): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:676) 08-10 10:42:05.964: D/Retrofit(11501): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:426) 08-10 10:42:05.964: D/Retrofit(11501): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:371) 08-10 10:42:05.964: D/Retrofit(11501): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:466) 08-10 10:42:05.964: D/Retrofit(11501): at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73) 08-10 10:42:05.964: D/Retrofit(11501): at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38) 08-10 10:42:05.964: D/Retrofit(11501): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321) 08-10 10:42:05.964: D/Retrofit(11501): at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220) 08-10 10:42:05.964: D/Retrofit(11501): at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278) 08-10 10:42:05.964: D/Retrofit(11501): at retrofit.CallbackRunnable.run(CallbackRunnable.java:42) 08-10 10:42:05.964: D/Retrofit(11501): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 08-10 10:42:05.964: D/Retrofit(11501): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 08-10 10:42:05.964: D/Retrofit(11501): at retrofit.Platform$Android$2$1.run(Platform.java:142) 08-10 10:42:05.964: D/Retrofit(11501): at java.lang.Thread.run(Thread.java:841) 08-10 10:42:05.974: D/Retrofit(11501): ---> END HTTP (no body)

rengwuxian commented 10 years ago

It looks like not fixed by OkHttp. I'm using Retrofit 1.6.1 with OkHttp 2.0.0, and this issue happens frequently in a TCL device (mobile, 4.2.2). And nothing is wrong on my Nexus 5.

Burbaka commented 10 years ago

Seams like adding OkHttp is the solution to this issue. At least it better then just reschedule request.

hongzhou85 commented 10 years ago

This is very bad performance for the server side, can you imagine one person make 2-3 request to succeed, and you multiply that by the number of users and their actions.

Mashnin commented 10 years ago

Issue not fixed. I'm using the latest Retrofit, and occasionally get exceptions mentioned before. Tried to use Retrofit with and without OkHttp. Log when using OkHttp matches the one that hongzhou85 posted. Log without OkHttp: java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203) at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:560) at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:813) at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274) at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486) at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73) at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38) at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321) at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240) at $Proxy2.fetchConfiguration(Native Method) ...

marcelpinto commented 10 years ago

Are you using okhttp 2.0?

I used to have this error and after adding it, it never happened again.

Marcel Pintó El 12/08/2014 18:08, "Mashnin" notifications@github.com escribió:

Issue not fixed. I'm using the latest Retrofit, and occasionally get exceptions mentioned before. Tried to use Retrofit with and without OkHttp. Log when using OkHttp matches the one that hongzhou85 posted. Log without OkHttp: java.io.EOFException at libcore.io.Streams.readAsciiLine(Streams.java:203) at libcore.net.http.HttpEngine.readResponseHeaders(HttpEngine.java:560) at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:813) at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274) at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486) at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73) at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38) at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321) at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:240) at $Proxy2.fetchConfiguration(Native Method) ...

— Reply to this email directly or view it on GitHub https://github.com/square/retrofit/issues/397#issuecomment-51936549.

Mashnin commented 10 years ago

As I said, I tried to use it, but error still happens.

BackPackerDz commented 10 years ago

I have the same bug and using okhttp doesn't solve my problem.

08-13 10:09:29.121: D/Retrofit(19633): java.io.EOFException 08-13 10:09:29.121: D/Retrofit(19633): at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:154) 08-13 10:09:29.121: D/Retrofit(19633): at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:189) 08-13 10:09:29.121: D/Retrofit(19633): at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101) 08-13 10:09:29.121: D/Retrofit(19633): at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:676) 08-13 10:09:29.121: D/Retrofit(19633): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:426) 08-13 10:09:29.121: D/Retrofit(19633): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:371) 08-13 10:09:29.121: D/Retrofit(19633): at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:466) 08-13 10:09:29.121: D/Retrofit(19633): at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73) 08-13 10:09:29.121: D/Retrofit(19633): at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38) 08-13 10:09:29.121: D/Retrofit(19633): at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321) 08-13 10:09:29.121: D/Retrofit(19633): at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220) 08-13 10:09:29.121: D/Retrofit(19633): at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278) 08-13 10:09:29.121: D/Retrofit(19633): at retrofit.CallbackRunnable.run(CallbackRunnable.java:42) 08-13 10:09:29.121: D/Retrofit(19633): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 08-13 10:09:29.121: D/Retrofit(19633): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 08-13 10:09:29.121: D/Retrofit(19633): at retrofit.Platform$Android$2$1.run(Platform.java:142) 08-13 10:09:29.121: D/Retrofit(19633): at java.lang.Thread.run(Thread.java:856) 08-13 10:09:29.121: D/Retrofit(19633): ---- END ERROR

glenwong commented 10 years ago

I'm running into the same issue. It's happening whether or not I use okhttp 2.0 or normal httpurlconnection. Only seems to occur on POST and only when I have an empty post body.

hongzhou85 commented 10 years ago

@JakeWharton Hi Jake, are u able to reopen and look into this issue since it seems like it is not resolved simply by using OKHttp2.0.

hboregio commented 10 years ago

I was having the same problem while doing a GET. In my case, what was triggering this error was the fact that this was an authenticated GET and I was encoding my key/secret using Base64.encodeToString() to generate the corresponding header. The problem was that the generated string contained a new line (\n) inside of it, causing the server to misbehave and return a null response. This null response was responsible for this EOFException. The solution was to simple remove the \n from the encoded string.

I know this is a specific problem to my app, but since there doesn't seem to be a consensus on how to reproduce this, I guess any sort of feedback helps.

edoardotognoni commented 10 years ago

+1

pomber commented 9 years ago

It looks that the more robust option is to retry the request. What is the best way to retry a request that failed with the EOFException? Could it be done from an ErrorHandler?

wlzch commented 9 years ago

Working well now after using okhttp

everald commented 9 years ago

Just run into this error on different 4.4.x Devices. Log:

HTTP POST http://www.app.koeln/api/test
Content-Type: application/json; charset=UTF-8
Content-Length: 80
{"brand":"56","location_radius":"26","location_zip":"50933","power_from":"4400"}
END HTTP (80-byte body)
ERROR http://www.app.koeln/api/test
java.io.EOFException
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:154)
    at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:189)
    at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101)
    at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:676)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:426)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:371)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:466)
    at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
    at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
    at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
    at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
    at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
    at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at retrofit.Platform$Android$2$1.run(Platform.java:142)
    at java.lang.Thread.run(Thread.java:811)
END ERROR

A request made with a rest client yields following headers.

Status Code: 200
Date: Wed, 05 Nov 2014 13:48:28 GMT
Content-Encoding: gzip
Vary: Accept-Encoding
Transfer-Encoding: chunked
Status: 200 OK
Connection: keep-alive
X-Request-Id: fdc00992-bcf2-474a-b48b-cfedd1134b0b
X-Runtime: 0.231811
Server: nginx
X-Frame-Options: ALLOW
Content-Type: application/json
Access-Control-Allow-Origin: *
Cache-Control: max-age=1800
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Content-Type,Accept
Expires: Wed, 05 Nov 2014 14:18:28 GMT

Tried with 'com.squareup.okhttp:okhttp:2.0.0' on the classpath. Any solution yet except the retry again one?

thib-rdr commented 9 years ago

Hi, same problem here, with 1.7.1, and Samsung Galaxy Tab GT-P5110.

Here is the log :

http://pastebin.com/CGj7p8pZ

aigc-in-all commented 9 years ago

Troubled by the death of me, how to solve?

thib-rdr commented 9 years ago

I solved it by switching to OkHttp.

aigc-in-all commented 9 years ago

@GaryHost

I just used okhttp 2.1.0 version, there are still problems, help look?

11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920): java.io.EOFException
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:192)
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:187)
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:78)
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:665)
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:429)
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:374)
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:221)
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
11-27 21:46:59.192: E/com.wumii.android.model.service.UnreadNotificationService(22920):     at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:25)
ar-g commented 9 years ago

I got this error and switch to okhttp did not help.

java.io.EOFException
            at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:192)
            at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:187)
            at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:78)
            at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:665)
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:429)
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:374)
            at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:469)
            at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
            at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
            at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
            at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
            at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
            at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at retrofit.Platform$Android$2$1.run(Platform.java:142)
            at java.lang.Thread.run(Thread.java:811)

versions:

    compile 'com.squareup.okio:okio:1.0.1'
    compile 'com.squareup.okhttp:okhttp:2.1.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
    compile 'com.squareup.retrofit:retrofit:1.8.0'

@GaryHost What is your version of okhttp?