Skip to content
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

proposal: x/net/http2: add Transport.WriteTimeout #48830

Open
neild opened this issue Oct 6, 2021 · 3 comments
Open

proposal: x/net/http2: add Transport.WriteTimeout #48830

neild opened this issue Oct 6, 2021 · 3 comments
Labels
Projects
Milestone

Comments

@neild
Copy link
Contributor

@neild neild commented Oct 6, 2021

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.

@gopherbot gopherbot added this to the Proposal milestone Oct 6, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 6, 2021

Change https://golang.org/cl/354431 mentions this issue: http2: add Transport.WriteTimeout

@ianlancetaylor ianlancetaylor added this to Incoming in Proposals Oct 13, 2021
@rsc
Copy link
Contributor

@rsc rsc commented Oct 13, 2021

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals Oct 13, 2021
@neild
Copy link
Contributor Author

@neild neild commented Oct 13, 2021

Perhaps a better name is (http2.Transport).WriteByteTimeout, since http.Server has a WriteTimeout field which applies to writing an entire response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants