PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, June 25, 2022

[FIXED] How to use Traefik for WebSocket backend

 June 25, 2022     reverse-proxy, sticky-session, traefik, websocket     No comments   

Issue

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?


Solution

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]


Answered By - Siyu
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing