Question

I'm running a WebSockets application on a node server. Everything works fine, except that my application is used in schools, and some of their firewalls apparently block WebSockets on port 80. I read that some ports like 843 are usually unblocked, but I want to test this before making any switch.

How to test for open WebSockets ports? e.g. try ports 80, 443 & 843 from the client-side and report which ones work? Any tutorials or code snippets would be great...

Was it helpful?

Solution

I've been using http://websocketstest.com/ to see blocking of my socket.io websockets. I just now came across a scenario too where a client had a firewall blocking traffic on port 80. Rather than insisting on them jumping through hoops I am now listen on 443, not necessary to use SSL either on that port for this purpose.

In nginx I am first redirecting all traffic to socket.test.com port 80 to port 443 thus:

server {
    listen              80;
    server_name             socket.test.com;
    rewrite             ^ http://test.com:443$request_uri?;
 }

then

server {
    listen 443;
    server_name  socket.test.com

    location / {
        proxy_pass http://127.0.0.1:3004;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

On port 3004 a socket.io server is accepting connections. Works!

2018 update: thanks to letsencrypt.com it's now trivial to add https certs so all this can be done with encryption on 443

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top