1

Why does my WebSocket connection always closes with 1006 error code, even when I use .close(1000) or .close(3000).

Interestingly, when using the WebSockets connection with Express.js and Express-ws, this does not happen, only when using our real API. Could it be something the server does? Isn't 1006 local only though?

Any help would be appreciated.

Thanks

Foxhoundn
  • 1,766
  • 2
  • 13
  • 19
  • I rather doubt we can help you without seeing your actual code that the error happens to, both client and server ends of the connection. Questions of the nature: "Why does my code do X?" must include that actual code. – jfriend00 Sep 05 '16 at 15:31
  • I've actually tried and used ws://echo.websocket.org and that one works fine so it's most likely a server issue. Will close the question. – Foxhoundn Sep 05 '16 at 15:32

1 Answers1

1

This answer says:

Close Code 1006 is a special code that means the connection was closed abnormally (locally) by the browser implementation.

If your browser client reports close code 1006, then you should be looking at the websocket.onerror(evt) event for details.

...

Ryan
  • 22,332
  • 31
  • 176
  • 357