Please take a moment to search the forum and documentation before posting a new topic.
If you’re creating a debugging post, please include the following info:
- Are you running your app locally or is it deployed? (It is deployed)
- If your app is deployed:
a. Is it deployed on Community Cloud or another hosting platform? (Using Nginx, Kuber)
b. Share the link to the public deployed app.
- Share the link to your app’s public GitHub repository (including a requirements file).
- Share the full text of the error message (not a screenshot).
- Share the Streamlit and Python versions.
Answers:
- It is deployed. There were no problems locally.
- Using Nginx, Kuber.
- -
- -
- Python 3.12.2, Streamlit 1.57.
Hello, colleagues!
There is a specific problem.
When the service is running in production, it reloads the tab every 30 seconds when st.fragments is open, which causes the script on the page to restart completely.
websocketPingInterval has no effect.
What is the reason for this, and how can it be fixed?
Hey there, thanks for sharing your detailed question and deployment setup!
This is a common issue when deploying Streamlit behind Nginx or Kubernetes: the app reloads every 30 seconds due to the WebSocket connection being dropped or timing out. This happens because Streamlit relies on a persistent WebSocket connection for session management, and many load balancers or reverse proxies (like Nginx, Kubernetes Ingress, or cloud load balancers) have a default timeout (often 30 seconds) for idle WebSocket connections. The websocketPingInterval setting in Streamlit does not override these external proxy timeouts.
To fix this, you need to increase the WebSocket timeout in your Nginx or Kubernetes Ingress configuration. For Nginx, set proxy_read_timeout and proxy_send_timeout to a higher value (e.g., 3600s). For Kubernetes, adjust the backend service or ingress controller’s timeout settings (like timeoutSeconds or request-timeout). Also, enable session affinity (sticky sessions) to ensure all requests from a user go to the same backend pod. For more details, see the guidance on session affinity and WebSocket management in Streamlit deployments and community discussions on proxy timeouts.
Sources: