-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ObjectDisposedException is thrown when disconnecting as a host, when at least 1 client is connected. #3118
Comments
Hi @Gitspathe , Could you take a look at this project and compare it with yours to see if there is something else you are doing that could be the cause? |
I was able to replicate my problem. It appears if you first call Shutdown on UnityTransport before shutting down the server, then the issue occurs. This happens in my project since I use multiple transports inter-changeably, so I had a manager set up which would first clean up transports before shutdown. I am able to work around this, but I would assume this isn't intended behaviour? |
@Gitspathe |
@Gitspathe
There are going to be several things that won't happen:
Is there a specific technical reason why you are shutting down the transport prior to the |
I handle the transport separately from the NetworkManager, in certain edge cases, because the Facepunch (Steam) transport requires you to start it for the Steam API to function. So typically I begin the game with Steam transport spawned, then I swap to Unity's UTP transport when playing single-player or without steam (shutdown facepunch -> start Unity UTP). Although I can work around this quite easily and it's more an issue with that 3rd party transport specifically. Although the order of operations makes a lot of sense in hindsight, would it be possible to add a better error message for when my situation occurs? This was just hard to debug since with only 1 player, everything appears to work fine, but then with 2+ you get strange error logs. I'd imagine the NetworkManager could just check if the Transport is shutdown or destroyed, and then give a warning/error based on that when you call Shutdown(). |
@Gitspathe |
Description
When disconnecting while running as a host, with at least one connected client, an ObjectDisposedException is thrown, causing further network functionality to not work as intended.
Reproduce Steps
Actual Outcome
An ObjectDisposedException is thrown, causing further network functionality to not work as intended. The exception is as follows:
ObjectDisposedException: The Unity.Collections.NativeList
1[Unity.Networking.Transport.ConnectionDataMap1+ConnectionSlot[Unity.Networking.Transport.ConnectionList+ConnectionData]] has been deallocated, it is not allowed to access it Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckReadAndThrowNoEarlyOut (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <f9983213a0c04feda5c20751005e16ae>:0) Unity.Networking.Transport.ConnectionDataMap
1[T].get_Item (Unity.Networking.Transport.ConnectionId connection) (at ./Library/PackageCache/[email protected]/Runtime/ConnectionDataMap.cs:42)Unity.Networking.Transport.ConnectionList.GetConnectionState (Unity.Networking.Transport.ConnectionId connectionId) (at ./Library/PackageCache/[email protected]/Runtime/ConnectionList.cs:57)
Unity.Networking.Transport.NetworkDriver.GetConnectionState (Unity.Networking.Transport.NetworkConnection connection) (at ./Library/PackageCache/[email protected]/Runtime/NetworkDriver.cs:1112)
Unity.Netcode.Transports.UTP.UnityTransport.DisconnectRemoteClient (System.UInt64 clientId) (at ./Library/PackageCache/[email protected]/Runtime/Transports/UTP/UnityTransport.cs:1179)
Unity.Netcode.NetworkConnectionManager.OnClientDisconnectFromServer (System.UInt64 clientId) (at ./Library/PackageCache/[email protected]/Runtime/Connection/NetworkConnectionManager.cs:1026)
Unity.Netcode.NetworkConnectionManager.DisconnectRemoteClient (System.UInt64 clientId) (at ./Library/PackageCache/[email protected]/Runtime/Connection/NetworkConnectionManager.cs:1055)
Unity.Netcode.NetworkConnectionManager.DisconnectClient (System.UInt64 clientId, System.String reason) (at ./Library/PackageCache/[email protected]/Runtime/Connection/NetworkConnectionManager.cs:1085)
Unity.Netcode.NetworkManager.ProcessServerShutdown () (at ./Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:139)
Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) (at ./Library/PackageCache/[email protected]/Runtime/Core/NetworkManager.cs:89)
Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) (at ./Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:192)
Unity.Netcode.NetworkUpdateLoop+NetworkPostLateUpdate+<>c.b__0_0 () (at ./Library/PackageCache/[email protected]/Runtime/Core/NetworkUpdateLoop.cs:287)`
Expected Outcome
The host is disconnected without an error, and network functionality (such as propagating disconnection messages to clients) continues to function as intended.
Environment
The text was updated successfully, but these errors were encountered: