com.unity.netcode.gameobjects: Server NetworkManager does not accept new connections from new clients if ONLY/FIRST client in game closes browser (webgl)

Description

if the last/only player in a Multiplay Server setup closes their browser to quit the game. The server does not accept new clients joining the game anymore…

Reproduce Steps

  1. Open the project (Unity 2022.3.x i use 8)
  2. Create a Project on Unity Services with: Multiplay Hosting, Lobby, Relay, Player Authentication, Matchmaker In Unity create a dedicated server build (keep aware of the name, you need it in Build Configuration later). Create a Build in Unity Services -> Multiplayer Hosting -> Buiids. By uploading the files you build from unity. After create build configuration, use the name of the build and search for xxx.x86_64 as the Game server executeable. -nographics -port $$port$$ -queryport $$query_port$$ -logFile $$log_dir$$/Engine.log create a fleet with build config and build and a region.
  3. Create a Matchmaker queue with name “WebFPSFFA” and a default pool choose the fleet. build config etc. and region, choose region of the fleet.
  4. Create a WebGL build (upload to itch or anywhere with https needed most likely)
  5. Spin up a game by starting the WebGL game -> main menu -> Lobby Browser -> Create game
  6. Keep in mind in might take 3-4 mins time when a new server needs to be spinned up, you can prevent this by having a min server available of 1 in the fleet. However there are (small) costs to this. Don’t forget to close the min servers available after to 0
  7. Leave the game by closing the browser. Reopen browser and re-open the game, try to join same game (by lobby join) This will cause an exception on the StartClient()
  8. Ensure there are NO other players in the game, otherwise the bug doesn’t happen.

Actual Outcome

StartClient() does not succeeds and time’s out.

Expected Outcome

New players should still be able to join the server by .StartClient().

Environment

  • OS: MacOS -> Build to WebGL and Dedicated Server Linux
  • Unity Version: 2023.3.8
  • Transport 2.4.0
  • NGO 1.11.0
  • Lobby 1.2.2
  • Multiplay 1.2.5
  • Matchmaker 1.1.5
  • Burst 1.8.18
  • Authentication 2.7.4
  • Unity services Core 1.13.0

Screenshot

Here you can see that there is no new Connection event happening after the last player closes the game by closing the browser. (10-30 seconds later the server kicks him out of the game, connectedClients = 0 after). And after that joining the game from Editor, webgl or any other instance does not work anymore Screenshot 2024-11-07 at 09 46 43

Additional Context

See ZIP project. NGO.zip

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18

Most upvoted comments

Hi @kevinstriker,

Could you please try the following changes?

In the StartRelay method of the Server.cs file, make these updates:

  • Change the RelayServerData protocol from "wss" to "dtls": RelayServerData relayServerData = new RelayServerData(allocation, "dtls");
  • Set UseWebSockets to false: NetworkManager.Singleton.GetComponent<UnityTransport>().UseWebSockets = false;

This should help resolve the re-connection issue.

https://github.com/user-attachments/assets/9c11834f-0eae-4621-a69a-e4d872497315

Cheers, Tristan

Leaving the game by using the Main Menu button will work properly. The game server will keep accepting new connections Leaving the game (and you’re the only player) with closing the browser, will cause the connection manager to be confused.

Ahhh… so when the last client disconnects by just closing the browser (i.e. non-graceful disconnect) it causes the issue to happen. That helps… let me talk with some of the services folks to see if there is any known issues with that.