Open qdhaiqiang opened 5 years ago
events.js:167 throw er; // Unhandled 'error' event ^
Error: unexpected server response (200) at ClientRequest.response (/usr/local/lib/node_modules/wsc/node_modules/ws/lib/WebSocket.js:719:15) at Object.onceWrapper (events.js:275:13) at ClientRequest.emit (events.js:182:13) at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:534:21) at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17) at Socket.socketOnData (_http_client.js:421:20) at Socket.emit (events.js:182:13) at addChunk (_stream_readable.js:280:12) at readableAddChunk (_stream_readable.js:265:11) at Socket.Readable.push (_stream_readable.js:220:10) Emitted 'error' event at: at ClientRequest.response (/usr/local/lib/node_modules/wsc/node_modules/ws/lib/WebSocket.js:721:12) at Object.onceWrapper (events.js:275:13) [... lines matching original stack trace ...] at Socket.Readable.push (_stream_readable.js:220:10)
Bit late to the party, but in case anybody else washes up here.. The clue is in the error line:
Error: unexpected server response (200)
This means you have connected to a web server, not a websocket server..
eg: I have a device with a web server on port 80, and a websocket server on port 81:
$ wsc ws://10.0.0.112:80
wsc ws://10.0.0.112:80
events.js:291
throw er; // Unhandled 'error' event
^
Error: unexpected server response (200)
at ClientRequest.response (/usr/local/lib/node_modules/wsc/node_modules/ws/lib/WebSocket.js:719:15)
at Object.onceWrapper (events.js:421:26)
etc....
$ wsc ws://10.0.0.112:81
Connected to ws://10.0.0.112:81
< CURRENT_ID:0
< ACTIVE_ID:0
< PING:0
>
我的环境里发生了这种错误,请问下是什么原因呢?