I'm using the WebSocket library ws for node.js and I'm trying to simulate an error event on the server that would trigger my error handling code:
ws.on('error', function(e) {
console.log("error occured");
});
I tried referencing an undefined variable in the on('message') event but that just crashed the whole server and the 'error' event never fired.
Can anyone tell me how to simulate a ws error event on the server?
Thank you!
Manually emitting the event should work (ws.emit('error', new Error('foo'))
) as well as calling the error
event handler directly (by pulling it out and naming it).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With