hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.34k stars 1.58k forks source link

HTTP/2 multiplexing? #2761

Open bagder opened 2 years ago

bagder commented 2 years ago

Version

Hyper/0.14.17 h2/0.3,9

Platform Linux x86_64

Description I build curl to use hyper for HTTP/2 over HTTPS, but when I try to multiplex h2 over a single connection I get http2 error: connection error received: frame with invalid size errors. Reproducible, every time.

I build curl and hyper from git and run this libcurl example: https://curl.se/libcurl/c/http2-download.html changed to download a 20MB file.

I cannot find any documentation explaining if I need to do anything special to get multiplexing going (I'm using the C API, is there any documentation at all?). I also can't figure out how to get hyper to tell me more info so that I can figure out more exactly what's going wrong.

seanmonstar commented 2 years ago

If HTTP/2 is enabled, mutliplexing is as well. The error message is coming from the frame decoder, that the bytes representing the frame size didn't match up with what was received. In my experience, this most commonly occurs when hyper expects the remote to speak HTTP/2, and the remote sends something else instead, such as an HTTP/1 response.

seanmonstar commented 2 years ago

For example, was this sent to an endpoint that expected ALPN to negotiate h2, and it wasn't, but the hyper HTTP/2 setting was still enabled? Or an endpoint that expected to do HTTP/2 Upgrade?

bagder commented 2 years ago

This is with HTTPS and negotiated h2 via ALPN. I can record the traffic fine with wireshark (SSLKEYLOGFILE!), and I can see the server sendGOAWAY with FRAME_SIZE_ERROR. Since curl+hyper works fine for regular h2 that isn't multiplexed, it feels like there's something wrong in how I do this. I just don't know how to figure it out!