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
- Open the project (Unity 2022.3.x i use 8)
- 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.logcreate a fleet with build config and build and a region. - Create a Matchmaker queue with name “WebFPSFFA” and a default pool choose the fleet. build config etc. and region, choose region of the fleet.
- Create a WebGL build (upload to itch or anywhere with https needed most likely)
- Spin up a game by starting the WebGL game -> main menu -> Lobby Browser -> Create game
- 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
- 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()
- 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
Additional Context
See ZIP project. NGO.zip
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18
Hi @kevinstriker,
Could you please try the following changes?
In the
StartRelaymethod of theServer.csfile, make these updates:RelayServerDataprotocol from"wss"to"dtls":RelayServerData relayServerData = new RelayServerData(allocation, "dtls");UseWebSocketstofalse: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
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.