Search code examples
node.jswebsocketsails.jssails.io.js

Why does my WebSockets handshake fail with ERR_CONNECTION_RESET?


I've just created a new sails.js app with

sails new testProject

Then I did

sails lift

Now I navigate to my address (http://153.92.xx.xxx:1337) and everything works.

sails app

However, I know that sails uses XHR by default but tries to upgrade to WebSockets if it can. No matter what I try I can't get WebSockets to work.

I can see that the app tries to connect but is just (pending) for about 18 seconds before it gives up. It then goes back to XHR.

websockets error

The error reads:

WebSocket connection to 'ws://153.92.xx.xxx:1337/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=8qjNepcGV5Rh3VvzAAAA' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET

What could I be doing wrong?

  • Sailsjs v0.11.2
  • Nodejs v0.12.7
  • Debian 8 x64
  • iptables has full ACCEPT on everything

Solution

  • I believe this is because of a personal firewall.

    • Changing the port from 1337 to 80 made everything work.
    • Accessing the site from a different machine worked ok.

    My best guess is that a personal firewall that was on my machine blocks websockets if they are not using "standard" ports.