net/http: HTTP requests with InsecureSkipVerify transport don't close TCP connections #16267
Labels
Comments
This has nothing to do with InsecureSkipVerify. You're leaking See the documentation under https://golang.org/pkg/net/http/#Transport :
Don't create a Transport for every request. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
go version
)?go version go1.6.2 linux/amd64
go env
)?Run the following program. It creates an HTTP server on :8000 and spawns a goroutine that sends GET requests to the server every 1 second. The server writes nothing in the response body; body-length = 0. The client makes GET requests and does a body.Close() without reading the body. Note that the transport has
InsecureSkipVerify
.Every request the client makes should get a 200 response from the server and immediately close the connection.
The client keeps making requests and gets 200 back, but the underlying TCP connection is never closed. It's stuck in the
ESTABLISHED
state perpetually.Check the open connections by running
ss | grep :8000
every few seconds. They keep growing.netstat n | grep :8000
also shows TIME_WAIT connections.Server()
solves the issue.InsecureSkipVerify
solves the issue.The text was updated successfully, but these errors were encountered: