Issue with sockets running on Ubuntu Server

Working locally, things seem to work ok.
However when I load this to docker on my remote server, I keep getting this error when I try and use sockets.

Could anyone throw me some suggestions as to what is going wrong?

Firefox can’t establish a connection to the server at wss://blocked-out/socket.io/?EIO=4&transport=websocket.

Local or ISP Firewall blocking the protocol ?

Not too sure, what ports does it run on? Or is there something else that should be opened? Really confused by this.

1 Like

It can run on any port. Is there a sockets server running on the machine?

There could be many different reason why you cannot access it.

What is your envirement setup? Docker? are there firewall on the server? etc… need more details.

My environment is completely different. This may be a good start

Sorry, the reply was meant for @gunnery

Oh yeah :rofl:

OK looking into this further, when I use (in the terminal):

curl "https://domain.com/socket.io/?EIO=4&transport=polling

I get a response of:

0{“sid”:“4zWkdD4clhoWy2_7AAAD”,“upgrades”:[“websocket”],“pingInterval”:25000,“pingTimeout”:20000,“maxPayload”:1000000}

Which I assume is working, however in the browser I am getting:

can’t establish a connection to the server at wss://domain.com/socket.io/?EIO=4&transport=websocket

I am using a reverse proxy to get the the docker container through the url.
Not really sure what is causing this as it seems as sockets is working on the server

Docker container running on Ubuntu server.
Yes there is a firewall but all the required ports are open as far as I can see.

Is the socket.io version of the client and server the same?

sorry to sound dumb, but how do I check that?

so on the server I am getting socket.io@4.5.4

Have you tried with Chrome?

There was a known issue with Firefox.

  • it’s dependent on whether you are using a self-signed or trusted cert ?

getting the same issue in chrome:
websocket.js:54 WebSocket connection to ‘wss://xxx.xxx/socket.io/?EIO=4&transport=websocket’ failed:

Are you using NGINX ?

I was but I swapped over to Apache to see if it would make any difference and it’s not :frowning:

This is most likely a reverse proxy/server configuration problem. Did you have proxy_pass config in place on NGINX ?

yep using a reverse proxy through the aapanel

Try this Apache HTTPD config

Header add Set-Cookie "SERVERID=sticky.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED

<Proxy "balancer://nodes_polling">
    BalancerMember "http://app01:3000" route=app01
    BalancerMember "http://app02:3000" route=app02
    BalancerMember "http://app03:3000" route=app03
    ProxySet stickysession=SERVERID
</Proxy>

<Proxy "balancer://nodes_ws">
    BalancerMember "ws://app01:3000" route=app01
    BalancerMember "ws://app02:3000" route=app02
    BalancerMember "ws://app03:3000" route=app03
    ProxySet stickysession=SERVERID
</Proxy>

RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) balancer://nodes_ws/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) balancer://nodes_polling/$1 [P,L]

ProxyTimeout 3