netlib icon indicating copy to clipboard operation
netlib copied to clipboard

Hosting a lobby behind VPN causes join to hang silently when STUN discovery fails

Open mentuat opened this issue 8 months ago • 0 comments

I’m encountering a problem when hosting a lobby from a user behind a VPN.
In this case, other players trying to network.join(lobbyCode) hang indefinitely — no connected event, no error, and no feedback to the app.

Debugging through chrome://webrtc-internals/, I observed:

  • Multiple icecandidateerror events occur (STUN discovery failures).
  • No usable ICE candidates (addIceCandidate) are generated.
  • As a result, the connection setup cannot proceed, and iceconnectionstatechange never fires.

Cause:

  • When the host cannot gather any usable ICE candidates (e.g., public IP discovery fails due to VPN blocking STUN), connection establishment is impossible.
  • Netlib doesn't appear to detect this failure case or emit any events to let the app know.

Impact:

  • Players joining a VPN-hosted lobby are stuck waiting forever, without any error or feedback.
  • The app cannot detect that the lobby is unreachable or retry automatically.

Suggestion:

  • Detect when ICE gathering results in no candidates (or ICE connection stays in 'new' state too long).
  • Emit an error event or a failed connection state after a timeout.
  • Additionally, consider allowing TURN server configuration for better support of VPN and NAT cases.

mentuat avatar Apr 26 '25 13:04 mentuat