-
Notifications
You must be signed in to change notification settings - Fork 18k
x/net/http2: client leaks connection after receiving GOAWAY frame #39752
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
Comments
There is no connection to close once your request is done.
On GOAWAY, the connection will be cleaned up which will remove it from the client connection pool. |
@fraenkel I'm expecting the connection being closed by client connection pool. However, If you send HTTP request in a loop, you will see many TCP connection left in ESTABLISHED state, and never closed. The number of file descriptors will exceed RLIMIT_NOFILE soon. This is effectively a DoS vulnerability. |
You are correct. It seems when we processGoAway, we mark the connection dead but fail to actually close the connection. |
There is an expectation that the server side would eventually close the connection. This would break the readLoop and cause a Close to occur. However, the server side is sending a GOAWAY but is not closing the connection. |
We should probably be a bit more proactive and force close after some timeout. We can also close earlier if we know we aren't awaiting for any response which is a possibility but easily determined. |
Change https://golang.org/cl/240341 mentions this issue: |
Change https://go.dev/cl/429060 mentions this issue: |
Once a connection has received a GOAWAY from the server, close it after the last outstanding request on the connection completes. We're lax about when we call ClientConn.closeConn, frequently closing the underlying net.Conn multiple times. Stop propagating errors on closing the net.Conn up through ClientConn.Close and ClientConn.Shutdown, since these errors are likely to be caused by double-closing the connection rather than a real fault. Fixes golang/go#39752. Change-Id: I06d59e6daa6331c3091e1d49cdbeac313f17e6bd Reviewed-on: https://go-review.googlesource.com/c/net/+/429060 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Damien Neil <dneil@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
After receiving GOAWAY frame from server, the underlying connection is not reused nor closed. The following code shows that the connection is not closed after a single HTTP request and
CloseIdleConnections()
.What did you expect to see?
The
TLS.Conn
should have been closed when I calltlsConn.Close()
in main.What did you see instead?
The
TLS.Conn
seems to be leaked and is not closed.tlsConn.Close()
returnsnil
.http2debug log
The text was updated successfully, but these errors were encountered: