[PR #137] [MERGED] Horizon extras: auto-reconnect (off by default) #2346

Closed
opened 2026-11-02 15:55:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/137
Author: @ludovic111
Created: 10/14/2026
Status: ✅ Merged
Merged: 10/14/2026
Merged by: @ludovic111

Base: main ← Head: feat/extras-reconnect


📝 Commits (4)

  • 43b45fa Horizon extras: auto-reconnect, off by default
  • 5797cf2 Auto-reconnect retries with the session's player name
  • ce9c1d3 Auto-reconnect: never after account session refusals, retry when session servers are down
  • 37043b3 net harness: the Disconnected screen gained auto-reconnect's retry

📊 Changes

12 files changed (+474 additions, -31 deletions)

View changed files

📝 crates/horizon-client/src/extras.rs (+18 -2)
📝 crates/horizon-client/src/front.rs (+19 -1)
📝 crates/horizon-client/src/game.rs (+1 -0)
📝 crates/horizon-client/src/game/extras.rs (+54 -0)
📝 crates/horizon-client/src/game/net_harness.rs (+1 -1)
📝 crates/horizon-client/src/game/remote.rs (+18 -3)
📝 crates/horizon-client/src/lib.rs (+1 -0)
📝 crates/horizon-client/src/multiplayer.rs (+39 -9)
📝 crates/horizon-client/src/net.rs (+21 -11)
➕ crates/horizon-client/src/reconnect.rs (+287 -0)
📝 crates/horizon-client/src/title.rs (+7 -0)
📝 docs/extras.md (+8 -4)

📄 Description

What

The auto-reconnect extra (NEXT-VERSION §6), off by default. Based on main; #135 and #136 are merged.

  • On the Disconnected screen after a lost multiplayer connection: "Reconnecting in N s (attempt k of 5)" with a Cancel reconnecting button (Horizon and Classic menu styles), then a new connection to the same address.
  • Backoff 5, 10, 20, 40, 60 s; at most 5 attempts, then it stops. The count resets only after staying connected for a minute, so a server that drops players right away never causes an endless loop. Leaving on purpose or cancelling forgets the attempts.
  • Respects the reason: only failed connections (errors, time-outs, refused connections while a server restarts) and the server's own "Server closed", "Timed out", "The server is full!", "Took too long to log in" or restart messages are retried. Kicks, bans, whitelists, version refusals, duplicate logins, idle kicks, online-mode refusals and any other server reason never are.
  • net.rs: Event::Disconnected now says whether the server gave the reason. Login-phase refusals (login::Disconnect, online mode, an invalid address) now count as given, so they're never retried.

How tested

  • cargo fmt --check, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace on the Mac mini.
  • New tests (reconnect.rs): the retry policy for vanilla's disconnect texts, the backoff sequence and its end, a short stay not resetting the count while a minute connected does, kicks and leaving reset, new addresses start over, the countdown rounding.
  • End to end on a vscreen with a local Horizon dedicated server I started and stopped (below).

End to end (files on ludodesktop in ~/code/horizon-parity/screens/extras/)

With a Horizon dedicated server I started on port 25599 (offline mode) and stopped afterwards:

  1. mp-whitelist-no-retry.png: the server's default whitelist refused the login: "You are not white-listed on this server!" and no countdown.
  2. Joined with the whitelist off, then stopped the server: mp-countdown.png, "Connection reset by peer", Reconnecting in 2 s (attempt 1 of 5) with Back and Cancel.
  3. Log: attempt 1 refused, "reconnecting in 10 s"; attempt 2 refused, "reconnecting in 20 s"; server restarted; attempt 3 joined: mp-rejoined.png (back in the world, minimap working).

That run showed the retry reconnecting under the options' player name instead of the one the session used; fixed (Retry carries the session's name; tested).

Rebased onto main after #161 (online-mode login)

  • net.rs still only adds the Ok/Err split behind from_server; #161's encryption and session-join code is untouched.
  • Classification (reconnect.rs, test online_mode_login_failures):
    • Never retried: account session refusals ("Failed to log in: Invalid session…", "…banned from playing online", "…Multiplayer is disabled…"), joining an online-mode server with no account signed in (net::NOT_SIGNED_IN), and the server's "Failed to verify username!".
    • Retried with the usual backoff: unreachable session servers on either side ("Failed to log in: The authentication servers are currently not reachable…", the server's "Authentication servers are down…").
  • Online-mode retries: a retry joins with the signed-in account through auth::current(). That account is held in memory for the whole run (a process-wide OnceLock filled from the launcher's session file, which is deleted on first read), so nothing is written to disk or logs. An expired token ends in "Invalid session", which is never retried.
  • Main's new net_harness.rs match on Disconnected { reason } now ignores the retry field.
  • On the Mac mini: cargo clippy --workspace --all-targets -- -D warnings clean, cargo test -p horizon-client passes (475 + 28 + 15 + 2), and tools/test_online_mode_parity.py passes 15/15.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/137 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/14/2026 **Status:** ✅ Merged **Merged:** 10/14/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `feat/extras-reconnect` --- ### 📝 Commits (4) - [`43b45fa`](https://github.com/horizon-rust/horizon/commit/43b45fabc7f713794183dbdd82b4d5d339ee81c3) Horizon extras: auto-reconnect, off by default - [`5797cf2`](https://github.com/horizon-rust/horizon/commit/5797cf2702e9584fcb619b6b41bf040d4cce06a2) Auto-reconnect retries with the session's player name - [`ce9c1d3`](https://github.com/horizon-rust/horizon/commit/ce9c1d3a5cc8b092454d6a21ce45c7b79f97e96e) Auto-reconnect: never after account session refusals, retry when session servers are down - [`37043b3`](https://github.com/horizon-rust/horizon/commit/37043b3dff2ff04a9e87dab709e96329ecff9acc) net harness: the Disconnected screen gained auto-reconnect's retry ### 📊 Changes **12 files changed** (+474 additions, -31 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/extras.rs` (+18 -2) 📝 `crates/horizon-client/src/front.rs` (+19 -1) 📝 `crates/horizon-client/src/game.rs` (+1 -0) 📝 `crates/horizon-client/src/game/extras.rs` (+54 -0) 📝 `crates/horizon-client/src/game/net_harness.rs` (+1 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+18 -3) 📝 `crates/horizon-client/src/lib.rs` (+1 -0) 📝 `crates/horizon-client/src/multiplayer.rs` (+39 -9) 📝 `crates/horizon-client/src/net.rs` (+21 -11) ➕ `crates/horizon-client/src/reconnect.rs` (+287 -0) 📝 `crates/horizon-client/src/title.rs` (+7 -0) 📝 `docs/extras.md` (+8 -4) </details> ### 📄 Description ## What The auto-reconnect extra (NEXT-VERSION §6), **off by default**. Based on main; #135 and #136 are merged. - On the Disconnected screen after a lost multiplayer connection: "Reconnecting in N s (attempt k of 5)" with a **Cancel reconnecting** button (Horizon and Classic menu styles), then a new connection to the same address. - Backoff 5, 10, 20, 40, 60 s; at most 5 attempts, then it stops. The count resets only after staying connected for a minute, so a server that drops players right away never causes an endless loop. Leaving on purpose or cancelling forgets the attempts. - **Respects the reason**: only failed connections (errors, time-outs, refused connections while a server restarts) and the server's own "Server closed", "Timed out", "The server is full!", "Took too long to log in" or restart messages are retried. Kicks, bans, whitelists, version refusals, duplicate logins, idle kicks, online-mode refusals and any other server reason never are. - `net.rs`: `Event::Disconnected` now says whether the server gave the reason. Login-phase refusals (`login::Disconnect`, online mode, an invalid address) now count as given, so they're never retried. ## How tested - `cargo fmt --check`, `cargo clippy --workspace --all-targets -D warnings`, `cargo test --workspace` on the Mac mini. - New tests (`reconnect.rs`): the retry policy for vanilla's disconnect texts, the backoff sequence and its end, a short stay not resetting the count while a minute connected does, kicks and leaving reset, new addresses start over, the countdown rounding. - End to end on a vscreen with a local Horizon dedicated server I started and stopped (below). ## End to end (files on ludodesktop in `~/code/horizon-parity/screens/extras/`) With a Horizon dedicated server I started on port 25599 (offline mode) and stopped afterwards: 1. `mp-whitelist-no-retry.png`: the server's default whitelist refused the login: "You are not white-listed on this server!" and **no countdown**. 2. Joined with the whitelist off, then stopped the server: `mp-countdown.png`, "Connection reset by peer", **Reconnecting in 2 s (attempt 1 of 5)** with Back and Cancel. 3. Log: attempt 1 refused, "reconnecting in 10 s"; attempt 2 refused, "reconnecting in 20 s"; server restarted; attempt 3 joined: `mp-rejoined.png` (back in the world, minimap working). That run showed the retry reconnecting under the options' player name instead of the one the session used; fixed (`Retry` carries the session's name; tested). ## Rebased onto main after #161 (online-mode login) - **net.rs** still only adds the Ok/Err split behind `from_server`; #161's encryption and session-join code is untouched. - **Classification** (`reconnect.rs`, test `online_mode_login_failures`): - Never retried: account session refusals ("Failed to log in: Invalid session…", "…banned from playing online", "…Multiplayer is disabled…"), joining an online-mode server with no account signed in (`net::NOT_SIGNED_IN`), and the server's "Failed to verify username!". - Retried with the usual backoff: unreachable session servers on either side ("Failed to log in: The authentication servers are currently not reachable…", the server's "Authentication servers are down…"). - **Online-mode retries**: a retry joins with the signed-in account through `auth::current()`. That account is held in memory for the whole run (a process-wide `OnceLock` filled from the launcher's session file, which is deleted on first read), so nothing is written to disk or logs. An expired token ends in "Invalid session", which is never retried. - Main's new `net_harness.rs` match on `Disconnected { reason }` now ignores the retry field. - On the Mac mini: `cargo clippy --workspace --all-targets -- -D warnings` clean, `cargo test -p horizon-client` passes (475 + 28 + 15 + 2), and `tools/test_online_mode_parity.py` passes 15/15. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 15:55:11 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#2346
No description provided.