gunicorn
gunicorn copied to clipboard
Set SO_KEEPALIVE on listener socket
Closes #3115
What scenario would this be useful in (or even observably different from defaults)? Are you concerned about the 2 hour timeframe, which I fear may not be easy to write a test for on non-Linux systems?
While the Linux default is 2 hours before keepalives start, and that is much higher than a typical Gunicorn HTTP keep-alive timeout, it's still a fine idea for cases where someone does set a very high HTTP keep-alive timeout or wants to detect stalled, long-lived requests or something. Maybe they set their system keepalive timeout to be very low.
Nevertheless, it's not enabled at all unless we set this socket option, so I think we probably should make that possible.
The original linked issue talks about closing long running connections. A good example of where this is useful is probably if someone uses gunicorn with an application that handles WebSocket upgrades.
I agree this should be an option. Using it as default will break some behaviors.
I am also unsure why it's needed for a proxy, HTTP connections should be stateless but it's good addion as an option anyway.
Indeed our host tells us to send keep-alive to avoid the proxy to close the request before it is answered. But now they came back on this statement and just ask us to use asynchronous request.
So I'm no more sure if this option will be useful for us but I can add the option.
commented related ticket. closing as WON4T DO IT