-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Description
There are currently two ways to detect a broken HTTP/2 connection:
- If a
ReadorWriteto thenet.Connfails. - If no frames are received from the connection for
ReadIdleTimeout, and no response is received from the subsequent ping withinPingTimeout.
Pings are a reliable way to detect a broken connection (with the fix for #48810), but there are times when it would be nice to passively detect an unresponsive peer without needing to actively ping them.
I propose adding an additional knob to http2.Transport:
// WriteTimeout is the timeout after which the connection will be closed
// if no data can be written to it. The timeout begins when data is written
// to the connection, and is extended if any bytes can be written.
// If zero, no write timeout is set.
WriteTimeout time.Duration
Unlike ReadIdleTimeout, WriteTimeout will apply only at the time we try to write to a connection. Unlike per-request timeouts, WriteTimeout applies to the connection as a whole.