Unexpected reruns when deployed to AKS


I am working on several Streamlit apps to be deployed on AKS with an application gateway ingress controller.

My problem is that the apps seem to spontaneously rerun at irregular intervals, anything form every few seconds to after a couple of minutes. This causes problems as it cancels long-running functions ungracefully, and it is generally annoying for the user.

After some debugging, it appears that something forces the websocket connection to reset.

This does not happen when running the program locally, nor when directly proxying into the server with kubectl port-forward ..., so it seems the problem is caused by the appgw ingress controller. Having read about some similar issues which were solved by increasing proxy timeouts, I’ve tried setting appgw.ingress.kubernetes.io/request-timeout: 86400 and increasing readinessprobe and livenessprobe timeouts. Still, the problem persists.

From the logs:

2023-12-06 07:22:06.061 Runtime state: RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED -> RuntimeState.NO_SESSIONS_CONNECTED
2023-12-06 07:23:45.458 Watcher created for ...
2023-12-06 07:22:06.507 Runtime state: RuntimeState.NO_SESSIONS_CONNECTED -> RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED

As this is likely an Appgw problem, this may be the wrong place to ask, but I thought maybe someone had experienced similar issues and could share some ideas.

I use Python 3.12 and Streamlit 1.28.2.

Hi, we are seeing the exact same issue, also with setting the request-timeout as you have. Have you found a solution to this?


streamlit does not produce WebSocket ping frames Β· Issue #8660 Β· streamlit/streamlit Β· GitHub seems to be the cause.