-
Notifications
You must be signed in to change notification settings - Fork 60
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
Number of CLOSE_WAIT connections when using with nginx #40
Comments
we had this problem too, and did a local patch right before btw calling
$ diff /usr/lib/python2.7/dist-packages/geventwebsocket/websocket.py.orig /usr/lib/python2.7/dist-packages/geventwebsocket/websocket.py
3c3
< from socket import error
---
> from socket import error, SHUT_RDWR
372a373,379
>
> try:
> # if we don't close, leaks open files in a CLOSE_WAIT state
> self.stream.handler.socket.shutdown(SHUT_RDWR)
> self.stream.handler.socket.close()
> except:
> pass note there is a comment in that method:
so whether this is "right" or not is arguable, but EOD it solved it for us. |
Yeah that makes sense. Wanna PR? Happy to merge in your changes :) |
i would, but it's more a fix for the lib you're using (gevent's websockets) than your project directly. and as i'm not using flask, i would feel uncomfortable proposing a change i don't know how to test. :) possibly a candidate for your |
gevent does not implement websockets, I'm not sure where you're getting that from. |
We are trying to use this flask plugin (version=0.4.4) to setup a notification server using redis / uwsgi / gevent and nginx(1.4.7). However we are noticing that on client disconnection many of the connections between nginx and the uwsgi flask application are left in CLOSE_WAIT state meaning that application never sends a FIN to nginx and leaves the connection hanging forever. This gets pretty bad eventually filling up the gevent async queue rendering the server unusable. Please see code below
I looked into the code further and uwsgi's implementation of websocket close and it seems like the close method is a noop. Please advise if we are doing something wrong here and if this can be fixed. Thanks!
The text was updated successfully, but these errors were encountered: