hyperium / h2

HTTP 2.0 client & server implementation for Rust.
MIT License
1.38k stars 279 forks source link

Protocol error : reset (remote) #805

Closed Mubelotix closed 1 month ago

Mubelotix commented 1 month ago

I have been experiencing a weird error nobody here seems to have encountered before when using h2.

Hyper(hyper::Error(Http2, Error { kind: Reset(StreamId(1), PROTOCOL_ERROR, Remote) }))

It happens upon sending any request to youtube through a recently negotiated http2 connection. This error only happens on youtube.com for some reason, all other servers work fine.

Request {
    method: GET,
    uri: "https://www.youtube.com/",
    version: HTTP/2.0,
    headers: {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
        "accept-language": "en-US,en;q=0.9",
        "sec-ch-ua": "\"Brave\";v=\"129\", \"Not=A?Brand\";v=\"8\", \"Chromium\";v=\"129\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Linux\"",
        "sec-fetch-dest": "document",
        "sec-fetch-mode": "navigate",
        "sec-fetch-site": "none",
        "sec-fetch-user": "?1",
        "sec-gpc": "1",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
        "host": "www.youtube.com"
    },
    body: None
}

I'm running hyper in the browser, compiled to wasm32-unknown-unknown. I'm using hyper_tls with ring, both with TLSv3 and TLSv2 enabled. I'm using the latest version (0.4.6) of this library with the default config at the exception of max_concurrent_reset_streams which I had to set to 0 due to another bug in h2.

seanmonstar commented 1 month ago

Google's ingress servers tend to wrongly return a PROTOCOL_ERROR if the host header is also set in an HTTP/2 request. Try not setting the host header.

(Note: it's definitely not supposed to be a PROTOCOL_ERROR, the HTTP/2 spec defines instances where it should be allowed. Google is of course allowed to reject anything they want, but it'd make more sense to reject with a 400 Bad Request and a message instead.)

Mubelotix commented 1 month ago

Thank you, this is helpful. Didn't believe it could be google's fault