Error: unexpected server response (200)

See original GitHub issue

I’m trying to connect as a socket client to a socket server with this code:

let socket = new WebSocket('wss://' + serverConfig['host'] + ':' + serverConfig['port'] + '/some/uri', {
    perMessageDeflate: false,
    rejectUnauthorized: false, // Server is self-signed for reasons.
});

In this specific instance, the host is 192.168.0.57 and the port is 443. Unfortunately, it throws this error:

Error: unexpected server response (200)
    at ClientRequest._req.on (/var/www/html/node_modules/ws/lib/WebSocket.js:650:26)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:473:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
    at TLSSocket.socketOnData (_http_client.js:362:20)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at TLSSocket.Readable.push (_stream_readable.js:134:10)

This is baffling, since I’m basically being told that it’s an error that the response was OK. I hope there’s something wrong with my request, but the error message is utterly uninformative.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
mcordingleycommented, May 1, 2017

I got it working by switching libraries. I don’t think there’s anything wrong with this one, just some other piece to my larger puzzle. I hate to close this without a full explanation. Thanks!

3reactions
JoweiBlogcommented, Jun 10, 2017

has someone fixed the issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the WebSocket error on status 200? - Stack Overflow
On a WebSocket connection you want a 101 Switching Protocols status response. Getting a 200 status response, probably means that the request ...
Read more >
Websocket not proxied, client receives response code 200
The NGINX server is using a Letsencrypt certificate, CF its own. Running a simple test: ... error: Unexpected server response: 200.
Read more >
Socket.io and Error: Unexpected server response: 200 - Help
Hi everybody! Please, help me. When i send ws request i received a error Error: Unexpected server response: 200.
Read more >
Error during WebSocket handshake: Unexpected response code
I am using webrtc publisher for streaming video recordings to wowza media server. I tried using my own security certificate but it showed ......
Read more >
Error during WebSocket handshake: Unexpected response code
Testing from the same pi server machine; Allowing Anonymous login; WebAPI 2015 R3 and WebAPI 2016 SP1. It seems to be happening after...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found