fasthttp
fasthttp copied to clipboard
Connections are sometimes kept `Active` with `DisableKeepalive` set to true
I have noticed that even when DisableKeepalive is set to true, there's sometimes connections that are kept open. I have indeed checked all my responses do return Connection: close. Regardless, it is sometimes keeping that connection as Active (I have debugged the connection status change). I have noticed this behaviour when I open multiple tabs and visit the endpoints directly or refreshing pages (trying to play around with a combination of those). It's quite replicable.
In another scenario (and perhaps it's expected?) When I setup an IdleTimeout and set DisableKeepalive to false if I visit an endpoint, then open a new tab, wait for the IdleTimeout and then visit the same URL in the new tab, it will show "Request Timeout", following that with a page refresh will trigger the correct response.
The first scenario is critical to have a graceful shut down, as the Active connection is never closed and the context deadline is hit in ShutdownWithContext (10 seconds for now).
The second senario is clearly undeserved as I do not want to show request timeouts to people. Wondering if that's the intended behaviour?
All those tests were done using Chrome on MacOS
I'm afraid that this sounds like a problem on the client side. If a server sends Connection: close the client is supposed to terminate the connection, but the server can't force this with anything besides something like IdleTimeout.
We should have the ability to close active connections when shutdown is happening... hitting a context deadline due client error is not precicely what I would expect
The problem is that we currently don't keep a list of connections and the state their are in. I would like to welcome anyone to make a pull request for this.