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

java.io.EOFException: \n not found: limit=0 content=… #5390

Closed
dannyZhou opened this issue Aug 23, 2019 · 6 comments
Closed

java.io.EOFException: \n not found: limit=0 content=… #5390

dannyZhou opened this issue Aug 23, 2019 · 6 comments
Labels
bug Bug in existing code needs info More information needed from reporter

Comments

@dannyZhou
Copy link

    api 'com.squareup.okhttp3:okhttp:4.1.0'

Occur sometimes.

W/System.err: java.io.IOException: unexpected end of stream on http://172.16.10.21:8880/...
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:205)
        at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:105)
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:82)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:37)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:82)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
W/System.err:     at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:84)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:71)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:112)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:87)
W/System.err:     at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.kt:184)
        at okhttp3.RealCall.execute(RealCall.kt:66)
        at com.lcbtn.utils.HttpUtils.get(HttpUtils.java:125)
        at com.lcbtn.utils.HttpUtils$2.run(HttpUtils.java:84)
        at java.lang.Thread.run(Thread.java:818)
    Caused by: java.io.EOFException: \n not found: limit=0 content=…
W/System.err:     at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.kt:231)
        at okhttp3.internal.http1.Http1ExchangeCodec.readHeaderLine(Http1ExchangeCodec.kt:210)
        at okhttp3.internal.http1.Http1ExchangeCodec.readResponseHeaders(Http1ExchangeCodec.kt:181)
    	... 19 more
$ curl http://172.16.10.21:8880/FSCPService/Program\?providerId\=cntv\&cityId\=7680\&programID\=CNTV2-1200064244\&cntv-version\=1006 -v 
*   Trying 172.16.10.21:8880...
* TCP_NODELAY set
* Connected to 172.16.10.21 (172.16.10.21) port 8880 (#0)
> GET /FSCPService/Program?providerId=cntv&cityId=7680&programID=CNTV2-1200064244&cntv-version=1006 HTTP/1.1
> Host: 172.16.10.21:8880
> User-Agent: curl/7.65.3
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Server: NGINX(CnPanel,LNMP)
< Date: Fri, 23 Aug 2019 02:59:34 GMT
< Content-Type: text/html
< Content-Length: 192
< Location: http://172.16.10.21:8880/FSCPService/Program/?providerId=cntv&cityId=7680&programID=CNTV2-1200064244&cntv-version=1006
< Connection: keep-alive
< 
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>NGINX(CnPanel,LNMP)</center>
</body>
</html>
* Connection #0 to host 172.16.10.21 left intact

@dannyZhou dannyZhou added the bug Bug in existing code label Aug 23, 2019
@dannyZhou
Copy link
Author

dannyZhou commented Aug 23, 2019

This occur sometimes, so my curl -v log may not cause the bug.....

private OkHttpClient client = new OkHttpClient.Builder()
        .connectTimeout(10, TimeUnit.SECONDS)
        .readTimeout(10, TimeUnit.SECONDS)
        .writeTimeout(10, TimeUnit.SECONDS)
        .retryOnConnectionFailure(false)
        .build();

I use retryOnConnectionFailure(false) Because of this?

@yschimke yschimke added the needs info More information needed from reporter label Sep 4, 2019
@yschimke
Copy link
Collaborator

yschimke commented Sep 4, 2019

Can you provide a test server we can test against? This is likely a problem with the response from the server, possibly differs because of different headers or connection negotiation. Without that, we can't help.

@fluidsonic
Copy link

I have the same issue when using Ktor (ktorio/ktor#1708 (comment)) but was able to trace it back to an issue with connection pooling when retryOnConnectionFailure is set to false, which is the default with Ktor.

The EOFException is likely thrown when a pooled connection was re-used but has timed-out on the server in the meantime.

I guess that is intended behavior? It's just that the exception is very confusing for developers.

@hanbing5210
Copy link

Check whether the CPU, memory, or hard disk load on the server is too high or causing the problem

@kotakamesh-angelone
Copy link

This occur sometimes, so my curl -v log may not cause the bug.....

private OkHttpClient client = new OkHttpClient.Builder()
        .connectTimeout(10, TimeUnit.SECONDS)
        .readTimeout(10, TimeUnit.SECONDS)
        .writeTimeout(10, TimeUnit.SECONDS)
        .retryOnConnectionFailure(false)
        .build();

I use retryOnConnectionFailure(false) Because of this?

The issue got resolved for me if I make it to true

@DaiyiLL
Copy link

DaiyiLL commented Aug 25, 2023

this is a high frequency bug for loser phone, when I can solve it by retryOnConnectionFailure(true).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in existing code needs info More information needed from reporter
Projects
None yet
Development

No branches or pull requests

7 participants