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
Set SO_KEEPALIVE on listener socket #3116
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this might be fine, I think it'd be even easier to say yes and merge with a configuration option. Any chance you want to update the PR to make this configurable?
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. So I'm no more sure if this option will be useful for us but I can add the option. |
ccbcbbc
to
5c2a23e
Compare
Closes #3115