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.

Recover from REFUSED_STREAM in HTTP/2

See original GitHub issue

OkHttp promises to persevere when there’s trouble, but it doesn’t recover from REFUSED_STREAM in HTTP/2. We should transparently retry when an HTTP/2 server returns a REFUSED_STREAM error.

We should set noNewStreams = true on the connection that refused the stream. That is a good enough policy that’s in spirit of the HTTP/2 spec: it’ll prevent the connection from being used for any future streams. Then when we retry we’ll get a different connection and with any luck that one will accept the stream.

We need a special case if the refused stream’s streamId is 1. That will let us recover when Nginx refuses request bodies sent before the settings ack. In that case we should retry on the same physical connection, which we can assume has since ACK’d the settings. It’s still a little bit racy, but unlikely to be a problem in practice. More discussion on this workaround on issue 2506 and on the http-wg list.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
dave-r12commented, May 21, 2016

A quick update: nginx attached a proposed patch on their issue tracker. I tested patch against OkHttp and it worked perfectly.

3reactions
rfc2822commented, May 15, 2016

Is this an okhttp or an nginx problem? People are starting to become nervous because clients which use okhttp (like DAVdroid) don’t work with their (up-to-date) nginx servers anymore… how do you recommend to handle this? Disable HTTP2 in okhttp?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[net] http2: retry requests after receiving REFUSED STREAM
http2 : retry requests after receiving REFUSED STREAM RoundTrip will retry a request if it receives REFUSED_STREAM. To guard
Read more >
HTTP/2 Frequently Asked Questions
These are Frequently Asked Questions about HTTP/2. ... who has the ability to inject data into the encrypted stream to “probe” the plaintext...
Read more >
Dealing with OkHttp HTTP/2 REFUSED_STREAM errors
We are Using OkHttp3 (v4.9.1) to establish h2c (HTTP/2 without TLS) connections in a highly concurrent fashion from a Spring Boot ...
Read more >
HTTP/2 Support on Avi Vantage
HTTP/2 is a binary protocol, while HTTP 1.1 is a text protocol. The followings are the benefits of HTTP/2 over HTTP/1.1: Request and...
Read more >
slb http2 — ACOS 1.0 documentation
Show http2 Statistics ... Statistics Data URI, /axapi/v3/slb/http2/stats ... 'frame_size_error': Frame Size Error; 'refused_stream': Refused Stream; ...
Read more >

github_iconTop Related Medium Post

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