Websockets don't work in docker swarm with scale > 1

Hi there,

we are using traefik as gateway into our docker swarm. We have about 100 container running and everything works fine. Until now.

We added a container that requires websocket connections. When only one container is running, everything works as expected. When we scale the container up, the websocket cannot connect anymore.
As soon as we scale down to one container it works.

Here is the Labels section of our container:

        traefik.backend.loadbalancer.method: "drr"
        traefik.backend.loadbalancer.swarm: "true"
        traefik.backend.loadbalancer.stickiness: "true"
        traefik.backend.loadbalancer.stickiness.cookieName: "sticky"
        traefik.enable: "true"
        traefik.docker.network: "SE"
        traefik.api.frontend.rule: "Host:api.XXXX(redacted)"
        traefik.port: "8080"

It seems that over people had similar issues but it was never quite the same and I tried all of those solutions. Maybe someone else knows what's going here.


Are you using the websockets from a browser or server2server?

From a Browser.

we tried different browsers and different computers.

The problem is:

    traefik.backend.loadbalancer.swarm: "true"

the cookie is not used in this case, as swarms internal load balancer is used, which will send each socket frame to a random backend server

I see. So I need to omit that line.

Don't quite understand then what that line means. All examples seem to suggest that I need this line when using Swarm mode. But I guess not.