Forum

Sails.js sockets.io websockets!

Sinterklaas
26 October 2015, 15:21
Hello,

I saw that 9.15 adds websockets support. Currently I am experimenting with websockets on node.js. More specific the sails.js framework. Now I want to run the sails.js application behind a reverse proxy on Hiawatha. Problem is however that I keep receiving the following error in the browser:

 
GET http://www.blablabla.nl/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_s…ascript&EIO=3&transport=polling&t=1445868133749-5&sid=hUs--Ny9U1tEEpGdAAAn 504 (Gateway Timeout)
Failed to connect socket (probably due to failed authorization on server) Error: Error: xhr poll error(…)
====================================
Socket was disconnected from Sails.
Usually, this is due to one of the following reasons:
-> the server was taken down
-> your browser lost internet connectivity
====================================

Socket is trying to reconnect to Sails...
_-|>_- (attempt #1)



|> Socket reconnected successfully after
\___/ being offline for ~1.044 seconds.


WebSocket connection to 'ws://www.blablabla.nl/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_plat…sdk_language=javascript&EIO=3&transport=websocket&sid=hUs--Ny9U1tEEpGdAAAn' failed: WebSocket is closed before the connection is established.
POST http://www.blablabla.nl/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_s…ascript&EIO=3&transport=polling&t=1445868139868-6&sid=hUs--Ny9U1tEEpGdAAAn 400 (Bad Request)


Am currently running Hiawatha on latest Arch Linux through openstack.

Thank you.
Hugo Leisink
27 October 2015, 09:30
I have no idea. I don't have much experience with node.js.
Sinterklaas
29 October 2015, 20:27
            location / {
proxy_pass http://127.0.0.1:1337/;
proxy_redirect off;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_hide_header X-Powered-By;
}


Just need equivalent of those rules!
Sinterklaas
29 October 2015, 20:28
Those are btw. from nginx.

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

These make it work on there.
Hugo Leisink
29 October 2015, 21:42
Hiawatha already takes care of those headers automatically.
This topic has been closed.