Io socket.io not working when used with Redis and Traefik

Wappler 5.3.2
Server Nodejs / Docker
DB Mysql Db cluster
Digital Ocean Deploy

io socket not working online in digital ocean containers

I have a container running locally and everything works perfectly with socket.io, but after deploying it to digital ocean the api connections stop working.

Being an image I figured everything I have local would play equally well online, I don’t know what I could be doing wrong.

in package.json

You might want to add more details as web sockets work fine for me on several droplets at DO.

Now the container doesn’t open anymore, it shows a Bad Gateway message

I really need sockte.io, could you tell me where I am going wrong @Teodor

Well you should check if all docker services are well running on your server. Select the remote target and see if it is all green. Otherwise check the logs from the web server as well.

If running Traefik check it also.

Everything is ok

only socket.io not working

I already reinstalled the node package but it doesn’t work

what can i do to see if soket.io is working on the server?

Hello @George , I know you are busy but I need a solution for this, it is really very complicated to finish an application and not be able to put it online.

I’m sure this app will be one of Wappler’s biggest cases :star_struck:

Deploying to Digital Ocean breaks socket.io

When I make a deployment to Digital Ocean and test my application on top of the generated IP, like http://meuip, it works normally. But as soon as I activate traefick on a custom domain, like https://meudominio.com.br, the socket.io stops working.

I would like to know how to solve this.

OBS. I tested the deployment on AWS with a custom domain and traefick works 100% with the same project.

@Teodor , @George

Good morning @patrick I know you are busy, but could you help me with this?
I’ve already done some error handling in the container but the socket.io still doesn’t work in Digital Ocean, I don’t know what else to do.

I really like Digital Ocean and feel great sadness seeing that socket.io doesn’t work via docker over there, please help me solve this problem.

@patrick, @George

Hi Adriano,

Well maybe some firewall is blocking your websockets. Check the firewall settings in the digital ocean dashboard and otherwise contact their customer support.

I contacted the Digital Ocean support and they said that I created the machine with my own configurations, that is, Wappler set up the container, uploaded and installed the application.
Everything was working perfectly until I put the Traefic after installing the traefic, the socket stopped working.

I believe this is not a Digital Ocean problem but a Wappler one, since it worked perfectly before Traefic.
Please, I ask you to upload an application from this one made in Wappler with socket io and point to a domain with SSL enabled to see where the error is.

Well we use all the same configuration for Digital Ocean or AWS, so if it works with AWS it should also work with Digital Ocean.

Do you have the site live somewhere so we can check?

Yes I will send you the private access to the website.

After long investigation with Adriano, I’m happy to say we found the problem.

It was Redis configuration when used with Traefik.

It was not joining the same network as the rest of the services when Traefik is used.

So when Traefik is used the Redis service also need:

    networks:
      proxy: ~

so it becomes in the docker-compose.yml

redis:
    image: 'redis:alpine'
    hostname: 'redis'
    networks:
      proxy: ~
    volumes:
      - 'redis-volume:/data'

we will fix that in the next update.

2 Likes

Does Traefik uses Redis at all? I’m thinking you might be doing a mistake, and instead what’s missing is the project’s network itself which might not be being created by default because you already specified a network “proxy” in the docker-compose file

Be really careful about this, you could be mixing Redis instances of different projects due to being on the same network “proxy”