Streamlit application integration via Traefik reverse proxy stuck on WebSocket error

Referring to an already existing issue on GitHub (Unable to use Streamlit behind HTTP proxy due to websocket errors · Issue #6305 · streamlit/streamlit · GitHub) which is now closed and whose replies weren’t of any help sadly, this post is supposed to emphasize particularly on the usage of Traefik as the proxy for integrating Streamlit applications.

The container in which the Streamlit application is running seems to be correctly integrated behind the traefik proxy as can be seen from the following screenshot. Though it remains in this “Please wait…” status by constantly throwing WebSocket errors in the console:

As you can see this application is bound in under a sub-domain “data-synthesis” that extends our URL.

What’s done by Traefik:
The request goes through two middlewares:

The first one is simply stripping the request to make it a root request again. The second middleware makes sure that the person accessing this application is actually logged in on our website (this is particularly why we use a proxy in the first place):

Both of them seem to work well.

When accessing the application via http, this is also going well:

I have invested quite some time into solving this problem myself also with the help of other posts from this forum or GitHub but changing the nginx configuration for our frontend didn’t change anything and I was unable to find any posts specifically related to Traefik.

Streamlit version: 1.11.0

Our frontend also has an nginx running. It’s config currently looks like this:

Do I need to configure our proxy in a specific way for wss protocol? Is the stripping the problem? Is the problem actually with my proxy or with the frontend nginx probably? If you have any experience with Traefik and Streamlit and can help out with this one, it would be highly appreciated!

I don’t have experience with Traefik, but I’ve successfully integrated Streamlit with NGINX and a Node.js-based reverse proxy, so I guess that it’s technically possible to get it working with Traefik.

In both cases, you need to ensure that the UPGRADE event (which is used to start the WebSocket connection) is forwarded adequately to Streamlit. Ping me if you want help!

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