OkHttp keeps getting StreamResetException: stream was reset: INTERNAL_ERROR when it's 200

2

I got StreamResetException: stream was reset: INTERNAL_ERROR from OkHttp. What's the problem?

Here's the logs.

I/okhttp.OkHttpClient: <-- 200 https://www.example.com/user/list (396ms)
I/okhttp.OkHttpClient: date: Fri, 04 Dec 2020 02:21:35 GMT
I/okhttp.OkHttpClient: content-type: application/json
I/okhttp.OkHttpClient: content-length: 99730
I/okhttp.OkHttpClient: server: nginx/1.18.0
I/okhttp.OkHttpClient: allow: GET, HEAD, OPTIONS
I/okhttp.OkHttpClient: x-frame-options: DENY
I/okhttp.OkHttpClient: x-content-type-options: nosniff
I/okhttp.OkHttpClient: referrer-policy: same-origin
D/okhttp.Http2: << 0x00000003  5792 DATA          
D/okhttp.Http2: << 0x00000003     4 RST_STREAM    
D/okhttp.TaskRunner: Q10092 canceled              : OkHttp ConnectionPool
D/force: okhttp3.internal.http2.StreamResetException: stream was reset: INTERNAL_ERROR
D/okhttp.Http2: >> 0x00000000     8 GOAWAY     
D/okhttp.TaskRunner: Q10096 finished run in 216 ms: OkHttp www.example.com

This is issued in Okhttp Gihub Repository. But any issues haven't solved yet.

I called the API like this

    @Headers("Content-Type: application/json")
    @GET("/user/list")
    fun getUserList(@Header("Authorization") jwt: String): Call<ArrayList<UserData>>

It's 200 but I get nothing. It's very weird behaviour..

Is it a server problem or my problem? (The server is Django).

android
django
okhttp
http2
asked on Stack Overflow Dec 4, 2020 by c-an

2 Answers

1

As suggested in OkHttp issue tracker, mostly likely this is a server error after the headers are sent.

https://github.com/square/okhttp/issues/3936

Typically error code is sent by a server to indicate a problem server-side. It could also happen if OkHttp’s stream reader crashes with an unexpected exception.

I'd suggest checking for server errors if you can, but you can see the Http2 frame from the server here

D/okhttp.Http2: << 0x00000003     4 RST_STREAM  
answered on Stack Overflow Dec 4, 2020 by Yuri Schimke
0

it was Nginx buffer size problem.

If you are using AWS EC2,

Go to /etc/nginx/default.d/server.conf

And set,

proxy_redirect off;
proxy_buffering off;
answered on Stack Overflow Dec 4, 2020 by c-an

User contributions licensed under CC BY-SA 3.0