-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
bug: reqwest always reuses http/2 connections #976
Comments
It's unfortunate that many things do that by default. The spec warns people should try to never set it lower than 100, but not to default cap at 100 XD
The HTTP2 spec claims that a client shouldn't open multiple connections. I know some clients do this anyway, but I'm not sure that's the best option.
This could possibly work, but has a problem of an unbounded buffer. Those are typically not great, but if we use a bounded buffer, then eventually requests won't be able to be buffered and backpressure will be needed by the user anyways... One option is to use something like |
This change aims to eliminate concurrency in the migration script. Excessive concurrent HTTP requests break the migration process (see seanmonstar/reqwest#976).
any news on this issue? |
See hyperium/h2#731. To summarize:
After hyperium/h2#731:
|
This is shipped in hyper 1.2.0. Just realised this is likely causing me problems interacting with various Google APIs |
Thanks for the reminder, yea so this should be fixed in 0.12 (released today or tomorrow, I hope). |
What is the issue?
When quickly creating a large amount of requests (150) in a short amount of time (within a few 100ms) to a single origin that serves HTTP/2, some requests will fail with the error
http2 error: protocol error: refused stream before processing any application logic
. I assume this is because all requests are multiplexed onto a single HTTP/2 connection, which causes the connection to exceed the maximum amount of concurrent streams that it can handle (SETTINGS_MAX_CONCURRENT_STREAMS
). This would explain why this only happens at more than ~100 requests, because most clients and servers setSETTINGS_MAX_CONCURRENT_STREAMS
to ~100 as recommended by the HTTP/2 spec.What do I expect?
Before reaching the maximum amount of concurrent streams for a connection, reqwest starts another HTTP/2 connection to that origin to handle requests with.
or
Reqwest buffers requests until the single HTTP/2 connection has free stream capacity again to handle the request.
How to reproduce?
A full reproduction can be found here: https://gist.github.com/lucacasonato/3dd98a7eb81516d20fd464a9c52a299f. Clone the gist, move
main.rs
tosrc/main.rs
and runcargo run
What this does:
reqwest::Client
You will see that out of 120 requests, about 15 will fail with the error
http2 error: protocol error: refused stream before processing any application logic
. You might need to increase the amount of requests to the origin if you don't see this request.Meta
Reqwest: 0.16.4
OS: Ubuntu 20.04
Rust: 1.45.0 stable
cc @ry
The text was updated successfully, but these errors were encountered: