[PR #1678] [MERGED] Multiplayer: switching servers on a Velocity network no longer kicks the client #3683

Closed
opened 2026-11-03 04:11:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/no-play-packets-in-reconfig


📝 Commits (1)

  • 0253d9b Multiplayer: no play packets after the client acknowledges a reconfiguration

📊 Changes

1 file changed (+65 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/net.rs (+65 -2)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What

Switching servers on a Velocity network (a server-selector menu, /server) kicked Horizon with "An internal error occurred in your connection". Velocity's log says why: exception encountered in ClientConfigSessionHandler ... A packet did not decode successfully (invalid data).

The proxy sends the client back to configuration for the switch. Horizon's network thread acknowledged it, but the game thread was still ticking the old level, and its client_tick_end went out right after configuration_acknowledged. In the configuration state that is serverbound packet 13, which isn't a valid packet there.

Capture of the switch (tools/net_capture.py between Horizon and Velocity 4.3.0):

61.6636 s2c play          start_configuration
61.6637 c2s play          configuration_acknowledged
61.6933 c2s configuration unknown_13 (0 bytes)   <- client_tick_end of the old level
61.7199 s2c configuration disconnect "An internal error occurred..."

Vanilla 26.3

ClientPacketListener.handleConfigurationStart runs on the game thread: it calls minecraft.clearClientLevel(new ServerReconfigScreen(...)) before it sends ServerboundConfigurationAcknowledgedPacket and switches the outbound protocol, so no play packet can follow the acknowledgement.

Fix

Session::send drops play packets while the connection is in configuration. The check runs under the writer lock, the same one the acknowledgement is sent and configuring is set under, so nothing can slip in between. Once configuration finishes, play packets go out again.

This is not what #1650 (cookies, store cookie, transfer packets) fixes: Velocity doesn't use transfer for a backend switch, and #1650 doesn't gate Session::send. Both are needed; they don't overlap.

How tested

  • New test net::tests::play_packets_wait_out_a_reconfiguration: a server sends start_configuration, the game sends client_tick_end during the configuration, the server's next packet must be finish_configuration, and after it the game's packets flow again. Without the fix it fails with left: Unknown(13, []), the same packet as in the capture.
  • Test bed (ThinkPad, offline mode): Velocity 4.3.0 (modern forwarding) → two Paper 26.3 build 222 backends; the lobby has DeluxeMenus with a [connect] survival item. Before: kicked with the error above. After: the switch works, Velocity logs SP1Bot -> survival has connected / lobby has disconnected, and the player stands in the survival world with its chunks loading.
  • python3 tools/lan_e2e.py --check tab and --check chat pass (a LAN guest's play packets still go out).

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 8a7831e58, 5 min 13 s)

Check Result
Scope ✅ 1 files, +65 −2
Cargo.lock ✅ unchanged
Public tree ✅ (1 s)
Python tests ➖ no Python change
rustfmt ✅ (4 s)
clippy ✅ (52 s)
tests: horizon-client ✅ 1200 passed (4 min 0 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 105 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 93 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Parity: none of the 105 harnesses listed touch a reconfiguration (Horizon's own servers never send start_configuration); left to CI.

Needs Ludovic

Nothing.

🤖 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/1678 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/25/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/no-play-packets-in-reconfig` --- ### 📝 Commits (1) - [`0253d9b`](https://github.com/horizon-rust/horizon/commit/0253d9bc47f9debca046edd6b14be1f550900485) Multiplayer: no play packets after the client acknowledges a reconfiguration ### 📊 Changes **1 file changed** (+65 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/net.rs` (+65 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What Switching servers on a Velocity network (a server-selector menu, `/server`) kicked Horizon with "An internal error occurred in your connection". Velocity's log says why: `exception encountered in ClientConfigSessionHandler ... A packet did not decode successfully (invalid data)`. The proxy sends the client back to configuration for the switch. Horizon's network thread acknowledged it, but the game thread was still ticking the old level, and its `client_tick_end` went out right after `configuration_acknowledged`. In the configuration state that is serverbound packet 13, which isn't a valid packet there. Capture of the switch (`tools/net_capture.py` between Horizon and Velocity 4.3.0): ``` 61.6636 s2c play start_configuration 61.6637 c2s play configuration_acknowledged 61.6933 c2s configuration unknown_13 (0 bytes) <- client_tick_end of the old level 61.7199 s2c configuration disconnect "An internal error occurred..." ``` ## Vanilla 26.3 `ClientPacketListener.handleConfigurationStart` runs on the game thread: it calls `minecraft.clearClientLevel(new ServerReconfigScreen(...))` *before* it sends `ServerboundConfigurationAcknowledgedPacket` and switches the outbound protocol, so no play packet can follow the acknowledgement. ## Fix `Session::send` drops play packets while the connection is in configuration. The check runs under the writer lock, the same one the acknowledgement is sent and `configuring` is set under, so nothing can slip in between. Once configuration finishes, play packets go out again. This is not what #1650 (cookies, store cookie, transfer packets) fixes: Velocity doesn't use `transfer` for a backend switch, and #1650 doesn't gate `Session::send`. Both are needed; they don't overlap. ## How tested - New test `net::tests::play_packets_wait_out_a_reconfiguration`: a server sends `start_configuration`, the game sends `client_tick_end` during the configuration, the server's next packet must be `finish_configuration`, and after it the game's packets flow again. Without the fix it fails with `left: Unknown(13, [])`, the same packet as in the capture. - Test bed (ThinkPad, offline mode): Velocity 4.3.0 (modern forwarding) → two Paper 26.3 build 222 backends; the lobby has DeluxeMenus with a `[connect] survival` item. Before: kicked with the error above. After: the switch works, Velocity logs `SP1Bot -> survival has connected` / `lobby has disconnected`, and the player stands in the survival world with its chunks loading. - `python3 tools/lan_e2e.py --check tab` and `--check chat` pass (a LAN guest's play packets still go out). **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 8a7831e58, 5 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 1 files, +65 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ (1 s) | | Python tests | ➖ no Python change | | rustfmt | ✅ (4 s) | | clippy | ✅ (52 s) | | tests: horizon-client | ✅ 1200 passed (4 min 0 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 105 affected, to run in CI (--quick): ambient_sound, arrow, audio_attributes, auto_jump, block_entity_anim, block_entity_render, block_entity_tickers, block_particles, block_removal, block_transformer, breaking_model, camera and 93 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | Parity: none of the 105 harnesses listed touch a reconfiguration (Horizon's own servers never send `start_configuration`); left to CI. ## Needs Ludovic Nothing. 🤖 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-03 04:11:23 +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#3683
No description provided.