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'); }) }); 
  • Is it closing with an error? I do not see your error handlers. - D-side
  • Well, I don’t get any obvious errors in the console, I’m using a Node for a couple of days, don’t tell me how and where to catch exceptions? I still think, can there be an error in what I send a regular string instead of bytes, but send it as bytes? - Kirill Stoianov
  • Wash mine is better to do JSON.parse () and JSON.stringify () if you send PS objects: ws.send, and not ws.emit? - pnp2000
  • I need to send bytes and not Json, there are no problems with json - Kirill Stoianov
  • and if to send through ws.emit, but not through ws.send? - pnp2000

0