There is a problem, after sending the data, the socket is closed, but it is closed if it ate to send data like ws.send(message, {binary: true, mask: true}) , but if you send data just like the string ws.send(message) , then the socket is not closes. What could be the error?
webSocketServer.on('connection', function (ws) { console.log('->> OnConnect'); ws.on('message', function(message,flags) { console.log('->> OnMessage'); ws.send(message, {binary: true, mask: true}); }); ws.on('close', function () { console.log('->> OnClose'); }) });