Skip to content

Fix periodic WebSocket disconnection#83

Merged
ICubE01 merged 4 commits into
mainfrom
bugfix/periodic-websocket-disconnection
Jul 18, 2026
Merged

Fix periodic WebSocket disconnection#83
ICubE01 merged 4 commits into
mainfrom
bugfix/periodic-websocket-disconnection

Conversation

@ICubE01

@ICubE01 ICubE01 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Idle rooms no longer drop the WebSocket and reconnect roughly once a minute
  • A reconnect now succeeds instead of looping, so a room left idle keeps receiving game and chat events

Backend

Bugfix

  • WebSocketConfig.configureMessageBroker enable STOMP heartbeats (10s each way) on the simple broker. SimpleBrokerMessageHandler leaves its heartbeat value unset unless a TaskScheduler is supplied, so the broker advertised 0,0 and an idle connection carried no traffic at all — nginx then closed it at the default 60s proxy_read_timeout.
  • WebSocketConfig.setMessageBrokerTaskScheduler inject the built-in scheduler through a @Lazy setter, per the reference documentation, to avoid a cycle between the built-in WebSocket configuration and this configurer. Qualified by name so heartbeats stay on the WebSocket pool if another TaskScheduler is ever declared.

Frontend

Bugfix

  • useStomp.tsx advertise a 10s heartbeat in both directions instead of disabling heartbeats, so the negotiated value is non-zero.
  • useStomp.tsx connect now takes a token factory and re-issues the token from beforeConnect on every attempt. The previous single token was captured at mount and, with its 5s TTL, was always expired by the time an automatic reconnect fired — JwtAuthenticationInterceptor rejected the CONNECT, so reconnects looped rather than recovering.

Enhancement

  • useStomp.tsx reconnect with exponential backoff capped at 60s, and drop the stale token when issuing a new one fails. A persistent failure previously retried once a second forever, each attempt re-sending a credential that could not succeed.

Chore

  • useStomp.tsx drop the debug callback. It logged every frame and, once heartbeats are enabled, roughly 1000 lines per hour per open tab.

@ICubE01
ICubE01 force-pushed the bugfix/periodic-websocket-disconnection branch from 9ad5e4c to 7731c86 Compare July 18, 2026 20:15
@ICubE01
ICubE01 merged commit 13b3973 into main Jul 18, 2026
2 checks passed
@ICubE01
ICubE01 deleted the bugfix/periodic-websocket-disconnection branch July 18, 2026 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant