-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
OkHttp3 - sll exception on reading response data #3596
Comments
Executable test case? |
My body content is here Volley works fine. See the server details . Full code is below:
|
Are you reproducing this error? If yes, is there any solution to fix it? |
I can reproduce the hang and then timeout, seems like a problem with the response from the server, Content-Length is 30, but I don't see those bytes come back.
Curl seems to handle it more gracefully by giving up.
|
Yeah, the response body is empty for this request. It is an expected behaviour. But okhttp doesn't return null when But it throws error response.body().string() or response.body().source() etc. I expect that
|
I believe the server is sending an incorrect header. You can send "Connection: close" as a header to make it clearer what is going on, but OkHttp is doing the right thing here.
|
I am not sure. Volley works properly. Also, curl doesn't throw any error.
|
ok. how about you check the status before reading the body? |
Look at here. It says that "The 304 response MUST NOT contain a message-body". If the status code is 304, we shouldn't read response body content. |
@swankjesse what is expected behaviour for 304, when server indicates there is a response, but it doesn't come? OR worse it does come so needs to be drained for keepalive? |
We handle 304s properly in our cache code. When we get a 304 when the cache isn’t involved we might be broken. We should confirm that we expect no response body. |
I don't think there is a right answer here. If we ignore the header, and the server sends a response the we break some other malformed servers with keepalives etc. okhttp/okhttp/src/main/java/okhttp3/internal/http/HttpHeaders.java Lines 221 to 226 in 9f8200d
|
Going to close this as won't fix. We risk breaking other clients by changing this behaviour, and ultimately the server should be fixed. |
Trace is here :
javax.net.ssl.SSLException: Read error: ssl=0x8797a780: I/O error during system call, Connection reset by peer
at com.android.org.conscrypt.NativeCrypto.SSL_read(Native Method)
at com.android.org.conscrypt.OpenSSLSocketImpl$SSLInputStream.read(OpenSSLSocketImpl.java:758)
at okio.Okio$2.read(Okio.java:139)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
at okio.RealBufferedSource.read(RealBufferedSource.java:46)
at okhttp3.internal.http1.Http1Codec$FixedLengthSource.read(Http1Codec.java:384)
at okio.Buffer.writeAll(Buffer.java:1005)
at okio.RealBufferedSource.readByteArray(RealBufferedSource.java:107)
at okhttp3.ResponseBody.bytes(ResponseBody.java:136)
The library triggers onResponse callback with 304 status code. It is true for my case. I can get content length of body, headers of response. But I couldn't get bytes or string of response body.
The error is thrown on body.bytes() method. Okhttp version is 3.8.1.
The text was updated successfully, but these errors were encountered: