WebSockets not working after migrating to Traefik 2.0

Hi,

I'm actually migrating my traefik 1.7 setup to traefik 2.0 and I'm facing one big problem with one application using websockets:

Socket-IO js-client -> traefik 1.7 -> uwsgi -> flask Socket-IO python app ... everything https-secured

While using traefik 1.7, my websocket client (Socket-IO js) requesting a websocket connection via protocol upgrade, connection is established and kept open ... all fine...

After upgrading to traefik 2.0 uwsgi is giving me a 400 bad request on protocol upgrade request. When using gunicorn, the protocol upgrade is done with response code 101 but the connection is closed immediately.

traefik debug log says: "begin ServeHttp on request ... Forwarding this request to URL ... completed ServeHttp on request" and Socket-IO is falling back to long polling requests..which is generally working, but not wanted...

When doing the protocol upgrade without https, the connection is kept open and communication is possible over webocket connection.

So, anyone else has this problem, or could give me any advice or link how to properly configure such a setup?

Thanks in advance!

Hi,

can confirm the same issue. After a successful http request there is no upgrade to the websocket connection and instead socket-io downgrades to simple http polling. Had to go back to v1.7 for now.
I believe this could be also a related issue: How to make WebSockets work with Traefik 2.0 (setting up Rancher)

Have a look at the related issue

traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto = https

did the trick

Solved it for me. Thx!
For local development had to use http instead of https.

Solved it for me too!!! Thanks a lot, mrvn!

Btw. I've also looked into the traefik sources (forwarded_header.go (because I've searched for "ws" / "wss" protocol), and was about trying that solution too, but read your answer first :smiley:

Hi Can you be more clear on this solution, we are in the same loop of websocket not working with traefik 2.3.7

Hi!

Does anyone know how to implement that using Kubernetes CRDs to use it in a Kubernetes cluster?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.