No reconnect after the server connection drops #4

Closed
opened 2026-09-25 11:43:39 +00:00 by selimaj-dev · 0 comments
Owner

Problem

ServiceClient connects and authenticates once, in initialize(). Nothing handles the connection dropping afterwards:

  • a server redeploy (every Coolify deploy disconnects everyone)
  • a network blip
  • the server's ping timeout closing the session

When that happens, session still points at the dead connection. Every later setCloak, setHat, buy*, emote and getPlayer call fails or hangs until the player restarts Minecraft. Notifications (other players' emotes and cosmetic changes) stop arriving too.

Fix

  • Detect the close through a close callback in session-java, or when a send fails.
  • Reconnect with exponential backoff (for example 1 s → 2 s → … capped at 60 s) and re-run the auth flow.
  • On success:
    • re-register the notification handlers (eventHandlers())
    • refresh the available cloaks and hats
    • clear or re-fetch the SaturnPlayer cache, since other players may have changed cosmetics meanwhile
  • Keep the calls that go through session safe while reconnecting: queue them or drop them with a log line, but don't hang.

Depends on session-java exposing close/error events (selimaj-dev/session-java#1 covers failing pending requests on close; close events belong there too).

## Problem `ServiceClient` connects and authenticates once, in `initialize()`. Nothing handles the connection dropping afterwards: - a server redeploy (every Coolify deploy disconnects everyone) - a network blip - the server's ping timeout closing the session When that happens, `session` still points at the dead connection. Every later `setCloak`, `setHat`, `buy*`, `emote` and `getPlayer` call fails or hangs until the player restarts Minecraft. Notifications (other players' emotes and cosmetic changes) stop arriving too. ## Fix - Detect the close through a close callback in `session-java`, or when a send fails. - Reconnect with exponential backoff (for example 1 s → 2 s → … capped at 60 s) and re-run the auth flow. - On success: - re-register the notification handlers (`eventHandlers()`) - refresh the available cloaks and hats - clear or re-fetch the `SaturnPlayer` cache, since other players may have changed cosmetics meanwhile - Keep the calls that go through `session` safe while reconnecting: queue them or drop them with a log line, but don't hang. Depends on `session-java` exposing close/error events (selimaj-dev/session-java#1 covers failing pending requests on close; close events belong there too).
Sign in to join this conversation.