Skip to content
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

WebSocket CLOSE_WAIT on disconnect #83

Closed
rbranson opened this issue Oct 22, 2010 · 4 comments
Closed

WebSocket CLOSE_WAIT on disconnect #83

rbranson opened this issue Oct 22, 2010 · 4 comments

Comments

@rbranson
Copy link

If I open a bunch of WebSocket connections and then drop them, they stay in the CLOSE_WAIT state, which uses up a file descriptor until a timeout (a few minutes). This means you can pretty quickly hit max file descriptors (typically set to 1024 or 4096) if you've got a lot of people connecting and disconnecting. One can use lsof or netstat to see all the open file descriptors in CLOSE_WAIT state. A fix in the websocket.js code is to destroy the connection after receiving the end event:

this.connection.addListener('end', function(){
            self.connection.destroy();
    self._onClose();
});

This seems to solve the problem.

@saschagehlich
Copy link

I absolutely agree. This drives me nuts, can't release my project because of that.

@prabgupt
Copy link

prabgupt commented Feb 8, 2011

Has this issue been fixed yet? I too am facing this problem and there are lots of connections in our env hanging on CLOSE_WAIT. To remove them, we don't have any option other than restarting the server again.

I tried workaround mentioned by Rick but still no luck. Can someone help in here as we don't want to keep re-starting out server periodically due to CLOSE_WAIT connections exceeding max file descriptors? I have already increased file descriptor limit and don't want to increase it more. Anyways even after doing so, still issue will remain.

@saschagehlich
Copy link

Well, I updated to node v0.3.6 and the latest socket.io which works fine

@prabgupt
Copy link

prabgupt commented Feb 8, 2011

thanks Sascha for such a quick reply :) I have updated socket.io. Let me try updating node as well and will then update this thread with my findings so as to let all know.

darrachequesne added a commit that referenced this issue Jul 4, 2024
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants