OkHttp 不断收到 StreamResetException: stream was reset: INTERNAL_ERROR when it's 200
OkHttp keeps getting StreamResetException: stream was reset: INTERNAL_ERROR when it's 200
我从 OkHttp 得到了 StreamResetException: stream was reset: INTERNAL_ERROR
。有什么问题?
这是日志。
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
Okhttp Gihub Repository发布。但是还没有解决任何问题。
我这样调用API
@Headers("Content-Type: application/json")
@GET("/user/list")
fun getUserList(@Header("Authorization") jwt: String): Call<ArrayList<UserData>>
它是 200,但我什么也没得到。这是非常奇怪的行为..
是服务器问题还是我的问题? (服务器是Django)。
正如 OkHttp 问题跟踪器中所建议的,这很可能是 headers 发送后的服务器错误。
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.
如果可以,我建议检查服务器错误,但您可以在此处看到来自服务器的 Http2 帧
D/okhttp.Http2: << 0x00000003 4 RST_STREAM
这是 Nginx 缓冲区大小问题。
如果您使用的是 AWS EC2,
转到/etc/nginx/default.d/server.conf
并设置,
proxy_redirect off;
proxy_buffering off;
StreamResetException:服务器发送错误代码以指示服务器端出现问题。这可能是由于 Nginx 缓冲区大小问题也可能发生,如果使用多个请求使单个服务器过载
我从 OkHttp 得到了 StreamResetException: stream was reset: INTERNAL_ERROR
。有什么问题?
这是日志。
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
Okhttp Gihub Repository发布。但是还没有解决任何问题。
我这样调用API
@Headers("Content-Type: application/json")
@GET("/user/list")
fun getUserList(@Header("Authorization") jwt: String): Call<ArrayList<UserData>>
它是 200,但我什么也没得到。这是非常奇怪的行为..
是服务器问题还是我的问题? (服务器是Django)。
正如 OkHttp 问题跟踪器中所建议的,这很可能是 headers 发送后的服务器错误。
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.
如果可以,我建议检查服务器错误,但您可以在此处看到来自服务器的 Http2 帧
D/okhttp.Http2: << 0x00000003 4 RST_STREAM
这是 Nginx 缓冲区大小问题。
如果您使用的是 AWS EC2,
转到/etc/nginx/default.d/server.conf
并设置,
proxy_redirect off;
proxy_buffering off;
StreamResetException:服务器发送错误代码以指示服务器端出现问题。这可能是由于 Nginx 缓冲区大小问题也可能发生,如果使用多个请求使单个服务器过载