Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why 1005 and ECONNREFUSED #5

Closed
yene opened this issue Jan 31, 2018 · 1 comment
Closed

Why 1005 and ECONNREFUSED #5

yene opened this issue Jan 31, 2018 · 1 comment
Labels

Comments

@yene
Copy link

yene commented Jan 31, 2018

hi,

websocket sometimes is a mystery to me.
Could you please explain why you don't reconnect on error 1005,
and why you reconnect on ECONNREFUSED.

thanks in advance

@lukeed
Copy link
Owner

lukeed commented Jan 31, 2018

Hey~!

As of 1.1.0, we are now reconnecting on 1005, which is actually not an error. It's just a status code that signifies no status code was given. I'd advise you look at #3 for insight and the list of status codes to figure out what they're tied to.

And ECONNREFUSED typically means that the socket (on the server-end) doesn't exist or isn't a socket. This (can) typically happen when your server has started and the WebSocket is trying to reconnect before the server is healthy again.

Without Sockette, this may look like:

const WebSocket = require('ws');

const ws = new WebSocket('ws://localhost:80');
ws.on('error', console.error);
{ Error: connect ECONNREFUSED 127.0.0.1:80
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1045:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1161:14)
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 80 }

Hope that helps! 🙌

@lukeed lukeed closed this as completed Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants