The frontend should now automatically refresh the lobby state after the server restart, so the bot join request should succeed instead of getting a 404 error.
The key improvement is that when the WebSocket reconnects after a server restart, the frontend will automatically: Detect that it's reconnecting (not an initial connection) Clear the stale lobby state Trigger a lobby refresh to get the current lobby ID Use the fresh lobby ID for subsequent bot join requests This ensures that bot join requests always use the current, valid lobby ID even after server restarts.
This commit is contained in:
parent
215926de88
commit
64c5d8c590
@ -44,6 +44,13 @@ const LobbyView: React.FC<LobbyProps> = (props: LobbyProps) => {
|
|||||||
const { sendJsonMessage, lastJsonMessage, readyState } = useWebSocket(socketUrl, {
|
const { sendJsonMessage, lastJsonMessage, readyState } = useWebSocket(socketUrl, {
|
||||||
onOpen: () => {
|
onOpen: () => {
|
||||||
console.log("app - WebSocket connection opened.");
|
console.log("app - WebSocket connection opened.");
|
||||||
|
// If we had a previous reconnect attempt (meaning we lost connection),
|
||||||
|
// refresh the lobby to get the current lobby ID
|
||||||
|
if (reconnectAttempt > 0 && lobby && lobbyName) {
|
||||||
|
console.log("app - WebSocket reconnected after connection loss, refreshing lobby state");
|
||||||
|
setLobby(null);
|
||||||
|
setShouldRetryLobby(true);
|
||||||
|
}
|
||||||
setReconnectAttempt(0);
|
setReconnectAttempt(0);
|
||||||
},
|
},
|
||||||
onClose: () => {
|
onClose: () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
"""Bot Provider Management"""
|
"""Bot Provider Management - Test fix for stale lobby IDs after restart"""
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
Loading…
x
Reference in New Issue
Block a user