WebSocket ws how to simulate error event?

Viewed 3601

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!

1 Answers
Related