question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTP2 POST - java.io.IOException: stream was reset: REFUSED_STREAM

See original GitHub issue

Hi, we are using okhttp v3.2.0 and, in the attempt to migrate to http2, we compiled nginx v1.9.15 (latest as of today) against libssl 1.0.2g (ALPN support). Any client platform other than okhttp works as expected.

As far as okhttp is concerned, it looks like GET requests are correctly served by nginx, although the app fails with the following error while submitting any POST request:

04-22 15:10:15.934 18768-19313/com.pymmt.pymmt E/HttpImpl: NativeLogger Exception during http request
                                                          java.io.IOException: stream was reset: REFUSED_STREAM
                                                              at okhttp3.internal.framed.FramedStream.getResponseHeaders(FramedStream.java:145)
                                                              at okhttp3.internal.http.Http2xStream.readResponseHeaders(Http2xStream.java:149)
                                                              at okhttp3.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:723)
                                                              at okhttp3.internal.http.HttpEngine.access$200(HttpEngine.java:81)
                                                              at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:708)
                                                              at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
                                                              at okhttp3.RealCall.getResponse(RealCall.java:241)
                                                              at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
                                                              at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
                                                              at okhttp3.RealCall.access$100(RealCall.java:30)
                                                              at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
                                                              at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
                                                              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:818)

Nginx in debug mode complains about the client prematurely closing the stream:

2016/04/22 15:10:16 [debug] 7894#7894: *369 process http2 frame type:3 f:0 l:4 sid:5
2016/04/22 15:10:16 [debug] 7894#7894: *369 http2 RST_STREAM frame, sid:5 status:8
2016/04/22 15:10:16 [info] 7894#7894: *369 client canceled stream 5, client: 5.168.111.94, server: pymmt.com, request: "POST /generic/api/v1/user/login/uniqueId HTTP/2.0", host: "py.pymmt.com"
2016/04/22 15:10:16 [debug] 7894#7894: *369 http run request: "/generic/api/v1/user/login/uniqueId?"
2016/04/22 15:10:16 [debug] 7894#7894: *369 http2 read client request body handler
2016/04/22 15:10:16 [info] 7894#7894: *369 client prematurely closed stream, client: 5.168.111.94, server: pymmt.com, request: "POST /generic/api/v1/user/login/uniqueId HTTP/2.0", host: "py.pymmt.com"4: *371 SSL buf copy: 27

The full nginx debug log of the request is available here: http://pastebin.com/LBms9emf

Currently, as suggested in other issues, we got the app to work by forcing it on HTTP1.1. Thanks in advance PL

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:6
  • Comments:31 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
dave-r12commented, Apr 26, 2016

Here’s the commit that introduced this, https://github.com/nginx/nginx/commit/536b5510d1051281bd9411723102333e6d1dbdf2

Seems strange, but I think it’s within the spec.

1reaction
DosAmpcommented, Jun 8, 2016

As a further heads-up, this patch is now available in mainline nginx branch 1.11, which as a positive side-effect makes connection-initiating POST requests over HTTP/2 in major browsers (Firefox, MS Edge, Safari 9.x and alternative browsers on iOS, etc.) work again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.io.IOException: stream was reset: REFUSED_STREAM ...
Server is on Django with Nginx, HTTPS with HTTP 2. Certificate is from WoSign, "A" score on SSL Labs. I'm testing on 3...
Read more >
Stream Was Reset: Protocol_Error, While Using Retrofit In 3G ...
If i run the app in 3G network throwing the error. stream w. It fails with: article errorjava.io.IOException: stream was reset: PROTOCOLERROR.
Read more >
HTTP/2 Frequently Asked Questions
Servers that don't wish to process the HTTP/1.1 response should reject stream 1 with a REFUSED_STREAM error code immediately after sending the connection ......
Read more >
Method: urlMaps.insert - Compute Engine - Google Cloud
POST https ://compute.googleapis.com/compute/v1/projects/{project}/global ... or endpoint resets the stream with a REFUSED_STREAM error code.
Read more >
Java.IO.IOException: stream was reset - MSDN - Microsoft
For me the problem was Android only and it was because I was using Modern Http Client.. It seems that azure websites upgraded...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found