'Socket.io on port 80

I've made a node application which listens on port 80, my application works fine on localhost, but when I run it on my VPS, I get a different log and a different result ( websockets just don't work )

A comparison between localhost's log and VPS' log:

Node's log on localhost

Node's log on VPS

As you see, in VPS, xhr is used instead of websocket after it says "info: transport end (socket end)"

I don't use any web server on my VPS and I ran my application as root.



Solution 1:[1]

Are you running a web server in front of your node app on your VPS? If so, make sure it is new enough and properly configured to do websockets. For instance, on modern Ubuntu the stock nginx is not new enough yet to support web sockets, so you have to install a separate package to get websocket support.

2nd guess: is there a proxy server between your browser and your VPS?

Solution 2:[2]

Have you run it as the super user on the VPS? Normal users are typically blocked from opening ports below 1024.

Solution 3:[3]

Our server hosted on VPS, using port 80. The io connection fired through cellular data and through WIFI fine, but in some wifi networks it didn't.

So we had used different port, then it works.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 psiphi75
Solution 3 Hussein mahyoub