Skip to content

x/net/http2: add Transport.WriteByteTimeout #48830

Closed
@neild

Description

@neild

There are currently two ways to detect a broken HTTP/2 connection:

  • If a Read or Write to the net.Conn fails.
  • If no frames are received from the connection for ReadIdleTimeout, and no response is received from the subsequent ping within PingTimeout.

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions