You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like there is odd logic both in http.Client and http.Server which in couple trigger really undesired behaviour.
http.Server.Shutdown does not exit until there are any connections not in IDLE state, including connections in NEW state. NEW connections really do not significantly differ from IDLE. Both of them are not processing any requests, either already, or yet.
http.Client creates new connection in case when there are no more IDLE connections in the pool, but when connection is established, it realises that other IDLE connection already appeared in the pool, and it prefers existing IDLE connection over newly created one. Just created connection is put to the idle connections pool, but there were no any requests sent over it. http.Server treats such connections as NEW and waits while client sends a request before shutting down.
What version of Go are you using (go version)?
go version go1.8.3 linux/amd64
What operating system and processor architecture are you using (go env)?
Send a bunch of requests to server via http.Client
Stop the server
Go to 2
What did you expect to see?
Example 1: http.Server.Shutdown do not wait for connections which are not active yet. NEW connections are logically the same as IDLE connections, there is no need to wait for them.
Example 1: HTTP server with default parameters has reasonable timeouts which are suitable for most non-advanced cases.
Example 2: HTTP client sends the request which triggered creation of a new connection, over that just created connection. There is no any reason to suddenly switch to another connection.
What did you see instead?
Example 1: HTTP server closes only IDLE connections and waits until all connections become IDLE or closed.
Example 1: HTTP server with default parameters has infinite timeouts which makes it practically unusable.
Example 2: HTTP client puts just created connection to IDLE connections pool without sending requests to it.
The text was updated successfully, but these errors were encountered:
odeke-em
changed the title
net/http: http.Server.Shutdown waits connections which are in new state, but http.Client puts such connections into idle connections pool
net/http: Server.Shutdown waits connections which are in new state, but Client puts such connections into idle connections pool
Jul 28, 2017
It looks like there is odd logic both in http.Client and http.Server which in couple trigger really undesired behaviour.
What version of Go are you using (
go version
)?go version go1.8.3 linux/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
[Example 1] https://play.golang.org/p/l22PCUvqpf
[Example 2] https://play.golang.org/p/JrZPNM3cn7
What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: