[GH-ISSUE #6342] Play with friends: a Windows relay refuses the host's next attach from the same port (TIME_WAIT), so the second guest can't join #2055

Closed
opened 2026-11-02 15:51:39 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @Ragbie on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6342

Originally assigned to: @Ragbie on GitHub.

🤖 Filed by Ragbie's AI agent (Claude Code, Opus 5.5), not by Ragbie personally.

On Windows, a host behind a relay that also runs on Windows can't take a second relayed guest for a couple of minutes after the first one leaves: the guest waits ~10 s and gets HostUnreachable ("Your friend's game didn't answer."). horizon-relay's tests/tunnel.rs a_short_code_through_a_self_hosted_relay shows it on every Windows run (tunnel.rs:200:63: called Result::unwrap() on an Err value: HostUnreachable); CI's Linux run passes.

What happens (upstream main 62bdd29b2, Windows 11, traced with prints and netstat):

  • The host attaches each relayed session from its direct port (host.rs serve_relayed → connect_relay(relay_url, port) → direct::connect_from), so every attach to the same relay uses the same address pair.
  • When the first session ends, the relay closes first and keeps that pair in TIME_WAIT: 127.0.0.1:57988 127.0.0.1:57990 TIME_WAIT.
  • The second attach from 57990 to 57988: Windows ignores a new SYN for a pair in TIME_WAIT (Linux accepts one), so connect_from gets TimedOut after 5 s, not AddrInUse, and its fallback to another port (only on AddrInUse / AddrNotAvailable) never runs. The relay's 10 s attach_wait runs out and it answers HostUnreachable.

Fix: when the host's attach from its direct port times out, try once more from any port, as connect_from already does for a port in use. Only the host's attach changes: the direct race's dials keep their port, since timing out is normal while punching.

Originally created by @Ragbie on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6342 Originally assigned to: @Ragbie on GitHub. > 🤖 Filed by Ragbie's AI agent (Claude Code, Opus 5.5), not by Ragbie personally. On Windows, a host behind a relay that also runs on Windows can't take a second relayed guest for a couple of minutes after the first one leaves: the guest waits ~10 s and gets `HostUnreachable` ("Your friend's game didn't answer."). `horizon-relay`'s `tests/tunnel.rs` `a_short_code_through_a_self_hosted_relay` shows it on every Windows run (`tunnel.rs:200:63: called Result::unwrap() on an Err value: HostUnreachable`); CI's Linux run passes. What happens (upstream `main` `62bdd29b2`, Windows 11, traced with prints and `netstat`): - The host attaches each relayed session from its direct port (`host.rs` `serve_relayed` → `connect_relay(relay_url, port)` → `direct::connect_from`), so every attach to the same relay uses the same address pair. - When the first session ends, the relay closes first and keeps that pair in TIME_WAIT: `127.0.0.1:57988 127.0.0.1:57990 TIME_WAIT`. - The second attach from `57990` to `57988`: Windows ignores a new SYN for a pair in TIME_WAIT (Linux accepts one), so `connect_from` gets `TimedOut` after 5 s, not `AddrInUse`, and its fallback to another port (only on `AddrInUse` / `AddrNotAvailable`) never runs. The relay's 10 s `attach_wait` runs out and it answers `HostUnreachable`. Fix: when the host's attach from its direct port times out, try once more from any port, as `connect_from` already does for a port in use. Only the host's attach changes: the direct race's dials keep their port, since timing out is normal while punching.
Author
Owner

@Ragbie commented on GitHub (Nov 1, 2026):

/claim

<!-- gh-comment-id:6562829226 --> @Ragbie commented on GitHub (Nov 1, 2026): /claim
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#2055
No description provided.