Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EOFException in RealBufferedSource.readUtf8LineStrict #1114

Closed
swankjesse opened this issue Nov 1, 2014 · 101 comments
Closed

EOFException in RealBufferedSource.readUtf8LineStrict #1114

swankjesse opened this issue Nov 1, 2014 · 101 comments
Labels
bug Bug in existing code
Milestone

Comments

@swankjesse
Copy link
Collaborator

A few people have reported this. Needs investigation & fix.

java.io.EOFException: null
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:154) ~[na:0.0]
    at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:189) ~[na:0.0]
    at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101) ~[na:0.0]
    at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:676) ~[na:0.0]
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:426) ~[na:0.0]
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:371) ~[na:0.0]
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:466) ~[na:0.0]
    at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105) ~[na:0.0]
@swankjesse
Copy link
Collaborator Author

I haven't been able to reproduce this. Punting to 2.2.

@swankjesse swankjesse modified the milestones: 2.2, 2.1 Nov 5, 2014
@swankjesse swankjesse added the bug Bug in existing code label Nov 11, 2014
@niqo01
Copy link

niqo01 commented Nov 27, 2014

@swankjesse I am seeing a few of those in production. How can I help debugging?

@swankjesse
Copy link
Collaborator Author

@niqo01 can you reproduce locally or are you getting this through Crashlytics/Bugsnag etc. ?

@niqo01
Copy link

niqo01 commented Nov 28, 2014

@swankjesse Getting through Crashlytics only. If you think about logs which would help debugging, I would be glad to add them to the next release.

@swankjesse
Copy link
Collaborator Author

@niqo01 any pattern in device maker or Android version?

I'll add something to OkHttp itself to provide more context when this is triggered.

@niqo01
Copy link

niqo01 commented Nov 29, 2014

@swankjesse you can have a look at the crashlytics report here: http://crashes.to/s/816499ead0b
I didn't recognized a possible pattern in device maker or Android version or specific HTTP request.

@floating-cat
Copy link

OkHttp 2.1.
Device: Coolpad 8297.
Version: Android 4.2.2.
Same issues. I can confirm this device would cause this EOFException (my two users have this device reported this).

This is the one user's device's info. I hope this may help you.

Model number                      Coolpad 8297
Android version                   4.2.2 MIUI V5
MIUI version (An android rom)     MIUI-4.9.26
Processor                         8-core 1.7GHZ
RAM                               2.00 GB
ROM                               8.00 GB
Baseband version                  MOLY.WR8.W1315.MD.W
                                  G.MP.V19.P2,2014/03/11
                                                   00:55
Kernel version                    3.4.39

Simliar comment can be found here:
#803 (comment)

@simtse
Copy link

simtse commented Dec 11, 2014

Hello @swankjesse , what I don't understand is why the error comes so quickly and not seeing a response log.

My experience is that either my server is down or a problem connecting to the server because of spotty connection that causes an EOFException for me.

12-10 17:21:27.453 30472-30652/? D/Retrofit log﹕ ---> HTTP POST https://placeholder.server.com//core/b1c51a7ec5204/
12-10 17:21:27.463 30472-30652/? D/Retrofit log﹕ User-Agent: Android
12-10 17:21:27.463 30472-30652/? D/Retrofit log﹕ Content-Type: application/json; charset=UTF-8
12-10 17:21:27.463 30472-30652/? D/Retrofit log﹕ Content-Length: 121
12-10 17:21:27.463 30472-30652/? D/Retrofit log﹕ ---> END HTTP (121-byte body)
12-10 17:21:29.275 30472-30652/? D/Retrofit log﹕ ---- ERROR https://placeholder.server.com//core/b1c51a7ec5204/
12-10 17:21:29.295 30472-30652/? D/Retrofit log﹕ 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)

@pflammertsma
Copy link

@swankjesse In the previous issue (#803), you theorized:

At first glance it looks like bad connection reuse, but that should be recovered from & retried automatically. Is this a POST request?

Are you referring to the fact that if the response gives HTTP 100 (HttpConnection:199), HttpConnection continues the loop to parse the StatusLine again (HttpConnection:187)?

I've attached the debugger to see if that's the case, and it's not; the exception is thrown the first time around, in my case on a HTTP 204.

I've been trying to put together a minimum working example of this problem, but to no avail. I'm only seeing it in a production environment where the API returns HTTP 204 with an empty body on a POST request.

I'm suspicious that perhaps the response coming in contains no newline '\n' character at all, as looking at RealBufferedSource:192 suggests that's the only cause of this exception. As the HTTP response should always contain at least one such character following the header, I'm properly puzzled.

On OkHttp 2.1.0, the line numbers appear to be slightly different; my stack trace is:

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 com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
    at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
    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)
    [...]

@ArthurSav
Copy link

Is there a fix for this? I get the exception quite often

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:818)

@swankjesse
Copy link
Collaborator Author

This might add some context:
square/okio#104

@pflammertsma
Copy link

Yes, this would indeed be useful. I haven't grabbed the latest for a new test, but it seems that the newline is missing in empty body responses (such as HTTP 204) from some servers. Oddly, it's entirely random.

I'll dump the new exception when I encounter it again.

@swankjesse
Copy link
Collaborator Author

Might be caused by attempting to parse SPDY or HTTP/2.0 as HTTP/1.1. We had a bug on desktop Java where our ALPN implementation wasn't always telling us the negotiated protocol.

With the new information in-hand from Okio's update, I'm going to punt this to 2.3 since there's no further action to take for the 2.2 release.

@swankjesse swankjesse modified the milestones: 2.3, 2.2 Dec 29, 2014
@johnjohndoe
Copy link

@swankjesse Please note my extensive comment on this Retrofit issue.

@pflammertsma
Copy link

@swankjesse After many (many!) tries where everything just works hunky dory, I've finally gotten it to fail again with OkHttp 2.2. I don't know what to say than that it appears to be completely at random.

As with @johnjohndoe's report, the buffer is simply empty. Unlike his report, this is coming from a Apache 2.2.15 on CentOS, running PHP 5.4.36.

java.io.EOFException: \n not found: size=0 content=...
    at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:200)
    at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:187)
    at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
    at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:791)
    at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:678)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:431)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:376)
    at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:471)
    at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
    at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
    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.locationFinishSession(Native Method)
    at com.vebego.ally.proxies.LocationSessionProxy$2.doRequest(LocationSessionProxy.java:47)
    at com.vebego.ally.SyncService$2.doInBackground(SyncService.java:269)
    at com.vebego.ally.SyncService$2.doInBackground(SyncService.java:259)
    at android.os.AsyncTask$2.call(AsyncTask.java:288)
    at java.util.concurrent.FutureTask.run(FutureTask.java:237)
    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at java.lang.Thread.run(Thread.java:841)

@pflammertsma
Copy link

Perhaps it would be useful for logging that the headers are output before the rest of the response body is attempted to be read? Presently, it bombs out with the ---- ERROR message line immediately after the ---> END HTTP line.

The issue is so terribly difficult to reproduce that I can't attach the debugger and hope for it to occur on a breakpoint.

@JakeWharton
Copy link
Collaborator

Jesse and I talked about a Retrofit-like logging system for stupid-easy
things like this. We have to be careful, though, because both headers and
the response body can come from different places. In this case you want the
headers logged before the body is read which is a very, very fine level of
logging.
On Jan 7, 2015 6:49 PM, "Paul Lammertsma" [email protected] wrote:

Perhaps it would be useful for logging that the headers are output before
the rest of the response body is attempted to be read? The issue is so
terribly difficult to reproduce that I can't attach the debugger and hope
for it to occur on a breakpoint.


Reply to this email directly or view it on GitHub
#1114 (comment).

@pflammertsma
Copy link

Yes, I can imagine, and looking at where those headers are read, it wouldn't be an ideal place to add logging.

I took another look at the stack trace, and if I understand correctly, noticed that it doesn't even get to reading the headers. The exception is thrown from HttpConnection:187, which seems to suggest that the response is a single line. With Jesse's added details in the stack trace, it appears that the response is actually completely empty. No status line, no headers, no body, nothing.

I'll throw together a bash script to test the API using cURL and see if it ever gets empty responses, but it sounds very strange to me.

@t-gao
Copy link

t-gao commented Jan 22, 2015

Hi, I met this problem every time trying to send an http request. Sure the Android OS of the device I used to test is bizarrely customized, but it's still worth a look.

Device Info:
device: Coolpad 9976A
Android version: 4.4.2
kernel: 3.4.39

Library Info:
gson-2.3.1
okhttp-2.1.0
okhttp-urlconnection-2.1.0
okio-1.0.1
retrofit-1.8.0

@t-gao
Copy link

t-gao commented Jan 22, 2015

An additional informartion:
When I was single-step debugging the code in DDMS, everything worked fine, I got the response correctly, but when I ran the APP, I got the exception.

@michal-luszczuk
Copy link

Our users also facing this issue:

Caused by java.io.EOFException
okio.RealBufferedSource.readUtf8LineStrict (RealBufferedSource.java:192)
com.squareup.okhttp.internal.http.HttpConnection.readResponse (HttpConnection.java:187)
com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders (HttpTransport.java:78)
com.squareup.okhttp.internal.http.HttpEngine.readResponse (HttpEngine.java:665)
com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute (HttpURLConnectionImpl.java:429)
com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse (HttpURLConnectionImpl.java:374)
com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode (HttpURLConnectionImpl.java:469)
retrofit.client.UrlConnectionClient.readResponse (UrlConnectionClient.java:73)
retrofit.client.UrlConnectionClient.execute (UrlConnectionClient.java:38)
retrofit.RestAdapter$RestHandler.invokeRequest (RestAdapter.java:321)
retrofit.RestAdapter$RestHandler.invoke (RestAdapter.java:240)

Devices:
Jiayu GF2 (4.2.2)
MyAudio Blade Smartphone
Akai Glory 3
Concorde Smartphone 5005NFC
THL T200

For some users it not work with WiFi connection, while on 3G all is ok.

@ArthurSav
Copy link

An update that maybe help others.

I had the same issue for a long time. Since i updated to retrofit v1.9.0, okhttp 2.2.0, urlconnection 2.2.0 i haven't encountered the problem since.

@epint
Copy link

epint commented Mar 19, 2015

@swankjesse your comment was probably ment for @coreform. We have a problem on real device.

@pflammertsma
Copy link

Jesse, I'm happy to run the test, but in the meantime I'd like to emphasize
that we're seeing the 0-byte issue intermittently on a Moto X 2014, Samsung
Galaxy S3 and LG G2. These just seem to be random devices from our test.

On Thu, Mar 19, 2015, 19:30 epint [email protected] wrote:

@swankjesse https://github.com/swankjesse your comment was probably
ment for @coreform https://github.com/coreform. We have a problem on
real device.


Reply to this email directly or view it on GitHub
#1114 (comment).

@swankjesse
Copy link
Collaborator Author

Thanks @pflammertsma. I think there are two distinct problems here. I'm going to close this issue and re-open two issues for each of the two problems.

  • 0-byte responses, issue 1517. My hypothesis is that these are just badly-behaving webservers, or proxy servers or something. In OkHttp 2.3 we're now including more information about the connection when this problem occurs. This happens to normal devices, like your Moto X 2014.
  • corrupt responses, issue 1518. My hypothesis here is that we're doing something to trigger another bug, and ending up with a corrupt buffer of data.

If you have an otherwise-normal, CTS-passing device that is getting corrupt, non-empty responses, then my hypothesis is invalidated & please let me know!

@naitikvithlani
Copy link

Any specific reason for this kind of EOF Exception error occurrence (using retrofit) ??? we all know this is issue facing with all, but i want to know exact problem behind this kind of issue.

@duanhongyi
Copy link

for android 4.2.2 (vivo y17t)

java.io.IOException: unexpected end of stream on Connection{59.46.115.124:11800, proxy=DIRECT@ hostAddress=59.46.115.124 cipherSuite=none protocol=http/1.1} (recycle count=0)
at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:210)
at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:830)
at com.squareup.okhttp.internal.http.HttpEngine.access$200(HttpEngine.java:95)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:823)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:684)
at com.squareup.okhttp.Call.getResponse(Call.java:272)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199)
at com.squareup.okhttp.Call.execute(Call.java:79)
at com.uu.shit.connection.NetToJavaRequest.requestServer(NetToJavaRequest.java:27)
at com.uu.shit.connection.ConnectionTest.doOwnTest(ConnectionTest.java:23)
at com.uu.shit.MainTest.doTest(MainTest.java:71)
at com.uu.shit.ShitActivity$2$1.run(ShitActivity.java:87)
at java.lang.Thread.run(Thread.java:838)
Caused by: java.io.EOFException: \n not found: size=1460 content=446174653a205468752c203236204d617220323031352030343a30333a303120...

@yq76034150
Copy link

apacheclient no problem,but use okhttp have this problem,log detail:

03-31 13:29:27.055: I/RetrofitCallback(3661): error.toString() :retrofit.RetrofitError: unexpected end of stream on Connection{:18083, proxy=DIRECT@ hostAddress=*** cipherSuite=none protocol=http/1.1} (recycle count=0)
03-31 13:29:45.255: I/RetrofitCallback(3661): error.getUrl() :http://****** error msg :unexpected end of stream on Connection{
:18083, proxy=DIRECT@ hostAddress=*** cipherSuite=none protocol=http/1.1} (recycle count=0)

@christophesmet
Copy link

I had the same issue and solved it.
I also got Caused by: java.io.EOFException: \n not found:

After closer inspection I notices that after the status code, the server didn't gave a description.
Example:
HTTP/1.1 500 Internal server error
Content-Type: text/xml; charset=utf-8

But this is broken:
HTTP/1.1 500
Content-Type: text/xml; charset=utf-8

So in my example the (somewhat exotic) http server didn't return a reason after the status code.
RFC2616 defines a reason after the status, so in my case it's not a fault of the library.
But I thought I might mention it, it might help someone.

@duanhongyi
Copy link

@christophesmet

Disable jit:
android:vmSafeMode="true"

see this:
#1518

@harmanjassal
Copy link

Got the same error in our prod environment. I have validated the health of Load balancer and instnace and both seem to be working fine.

Caused by: 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)
... 18 more

@DanDevine
Copy link

Currently getting the dreaded EOFException.

Running:
Samsung Galaxy Nexus
Android version 4.3

Project dependency:
compile 'com.squareup.retrofit:retrofit:1.9.0'

Adapter configuration:
RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint(host)
.setRequestInterceptor(interceptor)
.setLogLevel(RestAdapter.LogLevel.FULL)
.setConverter( new GsonConverter(gson))
.build();

Thanks, listening for updates.

@jixunmoe
Copy link

Maybe malformed/different version gzip reply from server(?)

    public static void main(String[] args) {
        final OkHttpClient client = new OkHttpClient();
        Request request = new Request.Builder()
                .url("http://sosu.qidian.com/ajax/search.ashx?method=Search&keyword=TEST")
                .addHeader("Referer", "http://sosu.qidian.com/")
                .build();

        Response response = null;
        String res = null;
        try {
            response = client.newCall(request).execute();
            res = response.body().string();
        } catch (IOException e) {
            e.printStackTrace();
        }

        if (response != null && res != null)
            System.out.println(res);
    }

By adding .addHeader("Accept-Encoding", "none") to above code I'm able to get the data I wanted. But the aim for me is to save the bandwidth, so this is only used as a temporary workaround.

To check if is header dependent error, I have also test with curl using same headers, and the result has been properly replied.

curl "http://sosu.qidian.com/ajax/search.ashx?method=Search&keyword=DD" -H "Accept: */*" -H "Referer: http://sosu.qidian.com/" -H "Connection: keep-alive" -H "Accept-Encoding: gzip" -H "User-Agent: okhttp/2.4.0" --compressed

GET /ajax/search.ashx?method=Search&keyword=DD HTTP/1.1
> Host: sosu.qidian.com
> Accept: */*
> Referer: http://sosu.qidian.com/
> Connection: keep-alive
> Accept-Encoding: gzip
> User-Agent: okhttp/2.4.0
>
< HTTP/1.1 200 OK
< Date: Fri, 24 Jul 2015 22:09:55 GMT
< Server: Microsoft-IIS/6.0
< X-Powered-By: ASP.NET
< X-AspNet-Version: 2.0.50727
< Set-Cookie: ASP.NET_SessionId=*hidden*; domain=.qidian.com; path=/; HttpOnly
< Set-Cookie: sosu_abtest=; expires=Thu, 23-Jul-2015 22:10:04 GMT; path=/
< Cache-Control: private
< Content-Type: text/plain; charset=utf-8
< Content-Encoding: gzip
< Transfer-Encoding: chunked
< X-Via: 1.1 czdx84:8107 (Cdn Cache Server V2.0), 1.1 ld15:6 (Cdn Cache Server V2.0)
< Connection: keep-alive
<
{ [5096 bytes data]

I've also created chunked gzip response using Apache and php, which okhttp had no problem:

=== BEGIN ===

<?php sleep(1);
for ($i = 0; $i < 80000; $i++) {
    echo mt_rand();
}
sleep(1);    ?>

=== END ===

.htaccess: SetOutputFilter DEFLATE

@christophesmet
Copy link

An ssl issue caused the no response bug with me.
For some reason, the error isn't show in the sslsocketfactory.
But doing the same call in python does show an ssl error.

@zourb
Copy link

zourb commented Jul 30, 2015

Got the same error

java.io.IOException: unexpected end of stream on Connection{p33.qhimg.com:80, proxy=DIRECT@ hostAddress=42.81.9.47 cipherSuite=none protocol=http/1.1} (recycle count=1)
at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:211)
at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:917)
at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:95)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:902)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:760)
at com.squareup.okhttp.Call.getResponse(Call.java:274)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201)
at com.squareup.okhttp.Call.execute(Call.java:81)
Caused by: java.io.EOFException: \n not found: size=0 content=...
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:200)
at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:191)
... 17 more

@ihgoo
Copy link

ihgoo commented Aug 1, 2015

OKHttp 2.4 doesn't work on some HUAWEI devices ..

eg: for android 4.2.2 (HUAWEI Y518-T00) wifi and 3G

compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'

Currently getting the dreaded EOFException:like this

2261-3324/com.bqs.wetime.fruits D/Retrofit﹕ java.io.IOException: unexpected end of stream on Connection{192.168.1.208:8080, proxy=DIRECT@ hostAddress=192.168.1.208 cipherSuite=none protocol=http/1.1} (recycle count=0)
            at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:211)
            at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
            at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:917)
            at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:95)
            at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:902)
            at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:760)
            at com.squareup.okhttp.Call.getResponse(Call.java:274)
            at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230)
            at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201)
            at com.squareup.okhttp.Call.execute(Call.java:81)
            at retrofit.client.OkClient.execute(OkClient.java:53)
            at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
            at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
            at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
            at retrofit.RxSupport$2.run(RxSupport.java:55)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
            at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at retrofit.Platform$Android$2$1.run(Platform.java:142)
            at java.lang.Thread.run(Thread.java:838)
     Caused by: java.io.EOFException: \n not found: size=9539 content=096f72672e737072696e676672616d65776f726b2e6a6462632e64617461736f...
            at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:200)
            at com.squareup.okhttp.internal.http.HttpConnection.readHeaders(HttpConnection.java:220)
            at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:199)
            at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
            at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:917)
            at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:95)
            at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:902)
            at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:760)
            at com.squareup.okhttp.Call.getResponse(Call.java:274)
            at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230)
            at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201)
            at com.squareup.okhttp.Call.execute(Call.java:81)
            at retrofit.client.OkClient.execute(OkClient.java:53)
            at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
            at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
            at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
            at retrofit.RxSupport$2.run(RxSupport.java:55)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
            at java.util.concurrent.FutureTask.run(FutureTask.java:234)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
            at retrofit.Platform$Android$2$1.run(Platform.java:142)
            at java.lang.Thread.run(Thread.java:838)

@krawa
Copy link

krawa commented Aug 11, 2015

Got the same error
ANDROID_VERSION=4.2.2
PHONE_MODEL=Quest 507

okhttp-2.4.0
okhttp-urlconnection-2.4.0
okio-1.4.0

@krawa
Copy link

krawa commented Aug 11, 2015

added android:vmSafeMode="true" and problem is gone!

@robfletcher
Copy link

I'm getting this from a server app where we're using OkHttp 2.2.0 under Retrofit. I'm making an HTTPS POST request to a slow-responding service and it ends up getting retried because this exception is thrown. The retry is causing us problems because the request isn't idempotent. If I set OkHttp's readTimeout lower it stops happening because the read times out before this exception is thrown.

Please let me know if I can help debugging.

@paul-hammant
Copy link

Hey dude, I can reproduce this with private code. In that code, I can switch between OkHttp which exhibits the issue, and UniRest which does not. With some effort I could make a standalone proof for y'all. RSVP :) mailto: @swankjesse

@ftomassetti
Copy link

I got the same issues. For some reason an empty string is not accepted when parsing headers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in existing code
Projects
None yet
Development

No branches or pull requests