Closed fishcharlie closed 2 months ago
Add a listener for the 'error'
event to the WebSocket
object.
const WebSocket = require('ws');
const server = new WebSocket.Server({ port: 0 }, function () {
const ws = new WebSocket(`ws://127.0.0.1:${server.address().port}`)
ws.on('open', function () {
ws._socket.write(Buffer.from('8200','hex'));
});
});
server.on('connection', function (ws) {
ws.on('error', console.error);
});
Is there an existing issue for this?
Description
No response
ws version
8.14.2
Node.js Version
20.10.0
System
System: OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm) CPU: (4) x64 DO-Premium-Intel Memory: 1.80 GB / 7.75 GB Container: Yes Shell: 5.2.15 - /bin/bash
Expected result
Server to not crash when client sends invalid message.
Actual result
Server crashes:
Attachments
No response