Unity-Technologies / com.unity.netcode.gameobjects

Netcode for GameObjects is a high-level netcode SDK that provides networking capabilities to GameObject/MonoBehaviour workflows within Unity and sits on top of underlying transport layer.
MIT License
2.13k stars 433 forks source link

Host disconnects when a client leaves while joining #2804

Closed Pixel-Gamer closed 8 months ago

Pixel-Gamer commented 8 months ago

Description I have an issue where when a client shutdowns their Network Manager while it is trying to join a lobby, the host of that lobby then breaks. This will also occur if the client closes the game through task manager while joining or if the connection is interrupted during the joining process.

How To Reproduce

  1. Host
  2. Join a client
  3. During Client join process shutdown Network Manager
  4. Send Client Rpcs and see if the host is receving them (if they aren't thats the issue)

Outcome The client part of the host(server, client) will disconnect, but the host's Network Manager will still be connected to other clients and running as the host. (DontDestroyWithOwner bool set to false) The host's player Object will be deleted (DontDestroyWithOwner bool set to True) The host's player NetworkObject will lose it's observers The host's game won't receive ClientRpc's anymore The host gets the OnClientDisconnect callback for when the Client part of the Host disconnects.

Expected Outcome All that should happen is the client should stop trying to join and not break the hosts' game

Environment

Additional Context I have tried reproducing the issue in a blank project to see if I could reproduce this issue, but I can't the blank project uses the same joining scripts and leaving methods in my other game. And the only other difference is the game that has this issue is using a hybrid of Unity Transport and Steam Networking Sockets Transport, but I don't think that is the issue because before start I have a bool I can toggle that switches the game's code from Unity Transport (local and for testing) and Steam Networking Sockets Transport (for game builds)

NoelStephensUnity commented 8 months ago

If you can't reproduce it with a reproduction project (i.e. blank project with the same basic scripts), then I would look to see if there is anything in the hybrid transport portions of your script and set the NetworkManager LogLevel to developer to see if you can get any additional information as to why the host is having this issue.

You might also try replacing your manifest.json file with this: "com.unity.netcode.gameobjects": "https://github.com/Unity-Technologies/com.unity.netcode.gameobjects.git?path=com.unity.netcode.gameobjects#develop",

PR #2789 fixes several issues with the shutdown sequence and notifications.

If you can't find anything that stands out in the hybrid transport portions of your script and the most current version of NGO does not resolve the issue, then (with LogLevel set to developer) could you post the host's log for a session where this occurs? I might be able to see something in that which could explain the issue.

Pixel-Gamer commented 8 months ago

I found out that the issue is with the Steam Networking Sockets Transport. So I posted an issue over where the Transport is from https://github.com/Unity-Technologies/multiplayer-community-contributions/issues/245#issue-2071579968