-
Notifications
You must be signed in to change notification settings - Fork 694
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
http-socket does not support Keep-Alive #1097
Comments
uwsgi --http-socket :8080 --http-keepalive --add-header "Connection: keep-alive" |
@Darvame Perhaps you could try this yourself, because it does not work: # wsgi.py
import gevent.monkey
gevent.monkey.patch_all()
import bottle
app = bottle.Bottle()
@app.route('/ping')
def ping():
return {
'message' : "pong",
}
if __name__ == '__main__':
bottle.run(
app,
server=bottle.GeventServer,
) Run the server:
Test keepalive:
The following invocation works as expected:
Test keepalive:
Here are a few backtraces from Python: https://github.com/unbit/uwsgi/blob/2.0.11.2/core/loop.c#L149
gevent: https://github.com/unbit/uwsgi/blob/2.0.11.2/plugins/gevent/gevent.c#L325
These lines also execute with |
Yes, does not work for me too :C |
You need uWSGI 2.1 (master branch) and the --http11-socket option. Once set the server will try to maintain the connection opened if a bunch of rules are respected. This is not a smart http 1.1 parser (to avoid parsing the whole response) but assumes the developer is generating the right headers. It has been added to support RTSP protocol for video streaming. |
Does this new option replace completely the old ones? I used
and I obtained this:
without any "Connection closed by foreign host." So it seems to work as a "Keep-alive" without any need of the old options
Does it mean that they are no more necessary? |
@depaolim i think --http11-socket may replace the add-header and http-keepalive options but i don't see it touching tcp stuff as so-keepalive does. |
Documentation has been updated thanks to @depaolim, closing this. |
I confirm (by testing it) that "http-keepalive" option works only with "http" (not "http-socket") in uWSGI 2.0. Why it is "http-keepalive" not working with "http-socket"? Is it any reason behind this? The "http11-socket" is a future option (in uWSGI 2.1 which for now is not released yet) so in reality I cannot use HTTP Keep-Alive in uWSGI not paying penalty of "http" option overhead. Btw, "http-keepalive" option value is a number which specify timeout (in seconds) after which an inactive connection is closed by server. How can I configure this timeout when I will use "http11-socket"? |
Seconding @marc1n, we observed the same problem.
UPDATE (14 Nov 2018): |
@marc1n what is your source for this? I see #2018, which seems to indicate that this is a boolean instead. |
@jf From the source code: https://github.com/unbit/uwsgi/blob/uwsgi-2.0/plugins/http/http.c#L658 |
Excellent, thanks! I see it now. On another note, if anybody has any recommendations for another server to check out that has proper http keep-alive support, I'd be glad to hear it. |
NOTE: Currently(uWSGI==2.0.21 2022.10.25) only |
The Native HTTP Support does not support HTTP Keep-Alive. It's easy to test with
uwsgi --http-socket :8080
and usingtelnet
to send a valid HTTP/1.1 request; uwsgi will close the socket after sending the response.A well-behaved HTTP/1.1 server will keep the socket open unless the client requests
Connection: Close
.The text was updated successfully, but these errors were encountered: