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

'error' event should be handled #54

Closed
nicokaiser opened this issue Apr 5, 2012 · 2 comments
Closed

'error' event should be handled #54

nicokaiser opened this issue Apr 5, 2012 · 2 comments

Comments

@nicokaiser
Copy link
Contributor

In WebSocketServer.js, strange errors occur:

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: This socket is closed.
    at Socket._write (net.js:474:19)
    at Socket.write (net.js:466:15)
    at WebSocketServer.<anonymous> (/opt/services/webpush/support/webpush-engine/node_modules/ws/lib/WebSocketServer.js:297:16)
    at /opt/services/webpush/support/webpush-engine/node_modules/ws/lib/WebSocketServer.js:326:25
    at WebSocketServer.handleHixieUpgrade (/opt/services/webpush/support/webpush-engine/node_modules/ws/lib/WebSocketServer.js:372:3)
    at WebSocketServer.handleUpgrade (/opt/services/webpush/support/webpush-engine/node_modules/ws/lib/WebSocketServer.js:147:61)
    at Server.handleUpgrade (/opt/services/webpush/support/webpush-engine/lib/server.js:66:11)
    at Server.<anonymous> (/opt/services/webpush/support/webpush-engine/lib/webpush-engine.js:47:12)
    at Server.emit (events.js:88:20)
    at Socket.<anonymous> (http.js:1425:14)

At the time the 'write' happens, there is no 'error' handler for the socket, that may be why the exception is not caught by the try/catch.

@nicokaiser
Copy link
Contributor Author

... maybe registering an error handler in 'handleUpgrade' solves the problem of the various "socket.end" calls crashing the server when clients unexpectedly close the connection.

@einaros
Copy link
Contributor

einaros commented Apr 6, 2012

Moving this discussion to the pull req you sent :)

@einaros einaros closed this as completed Apr 6, 2012
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

2 participants