How to use Traefik for WebSocket backend

删除回忆录丶 提交于 2019-12-11 01:53:00

问题


I am trying to configure Traefik for a WebSocket app, I just try with a simple WS app on docker: https://hub.docker.com/r/jmalloc/echo-server/

To test it I use Chrome SimpleWebSocketClient, so if I use the IP:Port of the app it works fine. If I add the Traefik DNS it fails, I just try with other WS server and clients and fails too, so it would be something of Traefik.

I just try with Traefik versions:

-v1.3.0/raclette
-v1.2.3/morbier

Those are my Traefik rules:

[backends.ws-test-backend]
    [backends.ws-test-backend.LoadBalancer]
      method = "drr"
    [backends.ws-test-backend.servers.server1]
    url = "ws://172.16.8.231:3000"

[frontends.ws-test-frontend]
  backend = "ws-test-backend"
  passHostHeader = true
  entrypoints = ["http","https","ws", "wss"]
    [frontends.ws-test-frontend.routes.manager]
    rule = "Host:ws-test.ikcloud.ikerlan.es"

What could it be wrong? Any recommended reverse proxy for doing this?


回答1:


You need to enable sticky session for your ws connections, otherwise it will be reconnecting all the time.

[backends]
  [backends.backend1]
    # Enable sticky session
    [backends.backend1.loadbalancer.stickiness]


来源:https://stackoverflow.com/questions/44430234/how-to-use-traefik-for-websocket-backend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!