我已经在Google Kubernetes Engine上部署了2个应用程序。
我的问题是,每隔10秒左右就会有一个WebSocket升级请求通过,我可以连接到套接字,但由于某种未知原因,websocket连接在10秒后丢失,并向/_stcore/stream发出另一个请求。这会不停地发生,导致每个变量都被删除。我想强调的是,即使我没有点击任何地方,这种情况也会发生,重新运行或刷新页面时,这会自动发生,无需任何用户输入。
我也在AWS上部署了没有Kubernetes和Docker的应用程序,它工作得很好,WebSocket连接只建立一次,而且很稳定。
你可以在下面找到pod的日志,很明显,连接每15秒中断一次,然后由于某种原因重新连接,我仍然不知道:
2023-04-08 11:02:12.805 Script run finished successfully; removing expired entries from MessageCache (max_age=2)
2023-04-08 11:02:42.542 Runtime state: RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED -> RuntimeState.NO_SESSIONS_CONNECTED
2023-04-08 11:02:43.050 in-event <InotifyEvent: src_path=b'/app/main.py', wd=1, mask=IN_OPEN, cookie=0, name='main.py'>
2023-04-08 11:02:43.050 Watcher created for /app/main.py
2023-04-08 11:02:43.050 Runtime state: RuntimeState.NO_SESSIONS_CONNECTED -> RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED
2023-04-08 11:02:43.112 Received the following back message:
rerun_script {
widget_states {
widgets {
id: "$$GENERATED_WIDGET_ID-03ad0d756f891356fcbde6a33ea79fe3-None"
int_value: 0
}
widgets {
id: "$$GENERATED_WIDGET_ID-7fb2e9aed3162f53d160852436451362-None"
file_uploader_state_value {
}
}
}
page_script_hash: "5bc02cefb3ea9e27f1a6776eabd1935d"
}
2023-04-08 11:02:43.113 Beginning script thread
2023-04-08 11:02:43.113 Running script RerunData(query_string='', widget_states=widgets {
id: "$$GENERATED_WIDGET_ID-03ad0d756f891356fcbde6a33ea79fe3-None"
int_value: 0
}
widgets {
id: "$$GENERATED_WIDGET_ID-7fb2e9aed3162f53d160852436451362-None"
file_uploader_state_value {
}
}
, page_script_hash='5bc02cefb3ea9e27f1a6776eabd1935d', page_name='')
2023-04-08 11:02:43.113 Disconnecting files for session with ID 1d33344d-ba21-4ed6-97d7-e93f1cf9fe80
2023-04-08 11:02:43.113 Sessions still active: dict_keys([])
2023-04-08 11:02:43.113 Files: 0; Sessions with files: 0
2023-04-08 11:02:43.114 in-event <InotifyEvent: src_path=b'/app/main.py', wd=1, mask=IN_OPEN, cookie=0, name='main.py'>
2023-04-08 11:02:43.148 Removing orphaned files...
2023-04-08 11:02:43.195 in-event <InotifyEvent: src_path=b'/app/.env', wd=1, mask=IN_OPEN, cookie=0, name='.env'>
2023-04-08 11:02:43.309 Script run finished successfully; removing expired entries from MessageCache (max_age=2)
2023-04-08 11:03:13.051 Runtime state: RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED -> RuntimeState.NO_SESSIONS_CONNECTED
2023-04-08 11:03:13.515 in-event <InotifyEvent: src_path=b'/app/main.py', wd=1, mask=IN_OPEN, cookie=0, name='main.py'>
2023-04-08 11:03:13.516 Watcher created for /app/main.py
2023-04-08 11:03:13.516 Runtime state: RuntimeState.NO_SESSIONS_CONNECTED -> RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED
2023-04-08 11:03:13.585 Received the following back message:
rerun_script {
widget_states {
widgets {
id: "$$GENERATED_WIDGET_ID-03ad0d756f891356fcbde6a33ea79fe3-None"
int_value: 0
}
widgets {
id: "$$GENERATED_WIDGET_ID-7fb2e9aed3162f53d160852436451362-None"
file_uploader_state_value {
}
}
}
page_script_hash: "5bc02cefb3ea9e27f1a6776eabd1935d"
}
2023-04-08 11:03:13.585 Beginning script thread
2023-04-08 11:03:13.585 Running script RerunData(query_string='', widget_states=widgets {
id: "$$GENERATED_WIDGET_ID-03ad0d756f891356fcbde6a33ea79fe3-None"
int_value: 0
}
widgets {
id: "$$GENERATED_WIDGET_ID-7fb2e9aed3162f53d160852436451362-None"
file_uploader_state_value {
}
}
, page_script_hash='5bc02cefb3ea9e27f1a6776eabd1935d', page_name='')
2023-04-08 11:03:13.585 Disconnecting files for session with ID 1d33344d-ba21-4ed6-97d7-e93f1cf9fe80
2023-04-08 11:03:13.585 Sessions still active: dict_keys([])
2023-04-08 11:03:13.585 Files: 0; Sessions with files: 0
2023-04-08 11:03:13.586 in-event <InotifyEvent: src_path=b'/app/main.py', wd=1, mask=IN_OPEN, cookie=0, name='main.py'>
2023-04-08 11:03:13.620 Removing orphaned files...
2023-04-08 11:03:13.669 in-event <InotifyEvent: src_path=b'/app/.env', wd=1, mask=IN_OPEN, cookie=0, name='.env'>
2023-04-08 11:03:13.784 Script run finished successfully; removing expired entries from MessageCache (max_age=2)
2023-04-08 11:03:43.517 Runtime state: RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED -> RuntimeState.NO_SESSIONS_CONNECTED
2023-04-08 11:03:44.005 in-event <InotifyEvent: src_path=b'/app/main.py', wd=1, mask=IN_OPEN, cookie=0, name='main.py'>
2023-04-08 11:03:44.005 Watcher created for /app/main.py
2023-04-08 11:03:44.005 Runtime state: RuntimeState.NO_SESSIONS_CONNECTED -> RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED
2023-04-08 11:03:44.067 Received the following back message:
rerun_script {
widget_states {
widgets {
id: "$$GENERATED_WIDGET_ID-03ad0d756f891356fcbde6a33ea79fe3-None"
int_value: 0
}
widgets {
id: "$$GENERATED_WIDGET_ID-7fb2e9aed3162f53d160852436451362-None"
file_uploader_state_value {
}
}
}
page_script_hash: "5bc02cefb3ea9e27f1a6776eabd1935d"
}
2023-04-08 11:03:44.068 Beginning script thread
2023-04-08 11:03:44.068 Running script RerunData(query_string='', widget_states=widgets {
id: "$$GENERATED_WIDGET_ID-03ad0d756f891356fcbde6a33ea79fe3-None"
int_value: 0
}
widgets {
id: "$$GENERATED_WIDGET_ID-7fb2e9aed3162f53d160852436451362-None"
file_uploader_state_value {
}
}
, page_script_hash='5bc02cefb3ea9e27f1a6776eabd1935d', page_name='')
2023-04-08 11:03:44.068 Disconnecting files for session with ID 1d33344d-ba21-4ed6-97d7-e93f1cf9fe80
2023-04-08 11:03:44.068 Sessions still active: dict_keys([])
2023-04-08 11:03:44.068 Files: 0; Sessions with files: 0
2023-04-08 11:03:44.069 in-event <InotifyEvent: src_path=b'/app/main.py', wd=1, mask=IN_OPEN, cookie=0, name='main.py'>
2023-04-08 11:03:44.102 Removing orphaned files...
2023-04-08 11:03:44.155 in-event <InotifyEvent: src_path=b'/app/.env', wd=1, mask=IN_OPEN, cookie=0, name='.env'>
2023-04-08 11:03:44.269 Script run finished successfully; removing expired entries from MessageCache (max_age=2)
2023-04-08 11:04:14.006 Runtime state: RuntimeState.ONE_OR_MORE_SESSIONS_CONNECTED -> RuntimeState.NO_SESSIONS_CONNECTED
2023-04-08 11:04:14.500 in-event <InotifyEvent: src_path=b'/app/main.py', wd=1, mask=IN_OPEN, cookie=0, name='main.py'>
这些是自动重复的日志,没有任何用户交互。
在aws中,WebSocket连接是稳定的,我希望webscoket连接对于部署在Google Kubernetees Engine中的应用程序也是稳定的。
1条答案
按热度按时间plicqrtu1#
原来问题出在默认的入口超时上。它是30秒,因此连接会丢失,每30秒重新建立一次。将超时更新为所需的值解决了这个问题。