How would I handle an error when a client disconnects? #49

Open
opened 2017-11-04 21:50:53 +00:00 by nitroxplunge · 1 comment
nitroxplunge commented 2017-11-04 21:50:53 +00:00 (Migrated from github.com)

I have a node.js server that interfaces with a website, and when I close a tab the server crashes due to an "Unhandled 'error' event"

I assume I need to add an error handler after .listen() but I cant figure out how to do it.

I know this is a noob question but I'm still learning about websockets.

I have a node.js server that interfaces with a website, and when I close a tab the server crashes due to an "Unhandled 'error' event" I assume I need to add an error handler after .listen() but I cant figure out how to do it. I know this is a noob question but I'm still learning about websockets.
ghost commented 2018-10-23 10:23:36 +00:00 (Migrated from github.com)

conn.on("error", function (code, reason) {
console.log("error msg")
});

conn.on("error", function (code, reason) { console.log("error msg") });
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: sitegui/nodejs-websocket#49
No description provided.