четверг, 1 августа 2019 г.

[nodejjs] [websocket] Specified protocol was not requested by the client fix

If you have this error:

Error: Specified protocol was not requested by the client.
    at WebSocketRequest.accept (/proj/node_modules/websocket/lib/WebSocketRequest.js:289:19)

this means you have to create a connection at client side like this:

var connection = new WebSocket('ws://127.0.0.1:3000', 'echo-protocol');

instead of this:

var connection = new WebSocket('ws://127.0.0.1:3000');

Also this means you should to handle it at server side not to crash your server.

Комментариев нет:

Отправить комментарий