Getting refreshed without reason every few minutes

I am trying to deploy streamlit under a corporate proxy, at xxx.xxx.xxx.xxx/some-url using k8’s

the stream lit app restarts automatically after a while on the other hand when accessed via IP under VPN it is working fine.

some logs

2021-01-29 15:59:50.282 Beginning script thread
2021-01-29 15:59:50.282 Running script <streamlit.script_request_queue.RerunData object at 0x7f2dcc05f910>
2021-01-29 15:59:50.283 Disconnecting files for session with ID e5db1ec6-bbe4-4d24-b198-2ab415e002e9
2021-01-29 15:59:50.283 Sessions still active: dict_keys([])
2021-01-29 15:59:50.283 Files: 0; Sessions with files: 0
2021-01-29 15:59:50.283 OnScriptRunnerEvent: ScriptRunnerEvent.SCRIPT_STARTED
2021-01-29 15:59:50.284 Popen(['git', 'version'], cwd=/app/file, universal_newlines=False, shell=None, istream=None)
2021-01-29 15:59:50.427 Popen(['git', 'rev-parse', '--show-toplevel'], cwd=/app/file, universal_newlines=False, shell=None, istream=None)
2021-01-29 15:59:50.584 Entering st.cache: <function init_model_pipeline at 0x7f2dea121af0>
2021-01-29 15:59:50.585 mem_cache key for __main__.init_model_pipeline: 72f1c08ecba295de2b2acbaae17fa896
2021-01-29 15:59:50.586 OnScriptRunnerEvent: ScriptRunnerEvent.SCRIPT_STOPPED_WITH_SUCCESS
2021-01-29 15:59:50.586 Deleting expired files...
2021-01-29 15:59:50.587 OnScriptRunnerEvent: ScriptRunnerEvent.SHUTDOWN
2021-01-29 15:59:50.650 Watcher created for /app/file/campaign_ml_tool/__init__.py
2021-01-29 15:59:50.712 Watcher created for /app/file/campaign_ml_tool/utils.py
2021-01-29 15:59:50.712 Watcher created for /app/file/campaign_ml_tool/sentiment_analysis.py
2021-01-29 15:59:50.714 Report finished successfully; removing expired entries from MessageCache (max_age=2)
2021-01-29 15:59:51.309 Shutting down (id=c160a53e-7ccf-4174-81ed-27c0a9ed1b72)
2021-01-29 15:59:51.309 Disconnecting files for session with ID c160a53e-7ccf-4174-81ed-27c0a9ed1b72
2021-01-29 15:59:51.309 Sessions still active: dict_keys([])
2021-01-29 15:59:51.309 Files: 0; Sessions with files: 0
2021-01-29 15:59:51.309 Deleting expired files...
2021-01-29 15:59:52.015 Watcher created for /app/file/app.py
2021-01-29 15:59:52.015 ReportSession initialized (id=ffc62071-a7f8-4bcf-a246-b2e3dba5e460)
2021-01-29 15:59:52.015 Created new session for ws 139835145973376. Session ID: ffc62071-a7f8-4bcf-a246-b2e3dba5e460
2021-01-29 15:59:52.015 Server state: State.ONE_OR_MORE_BROWSERS_CONNECTED -> State.ONE_OR_MORE_BROWSERS_CONNECTED
2021-01-29 15:59:52.164 Received the following back message:
rerun_script {
  widget_states {
  }
}

Hi @Gautham_Santhosh , welcome to the Streamlit community :slight_smile:

I do not know the details of how your app (in particular the networking) is setup, but we have seen similar behavior due to the default connection timeout in K8s Ingress. Streamlit apps use websocket connections, which are long-lived. The connection gets reset after the timeout duration and it causes the app to re-run. You may want to check the restart frequency and see if it matches the timeout interval configured in your K8s Ingress or LoadBalancer resources.

Hope this helps,
Amey