Search Unity

DisconnectReason is empty on the client

Discussion in 'Netcode for GameObjects' started by afavar, Mar 22, 2023.

  1. afavar

    afavar

    Joined:
    Jul 17, 2013
    Posts:
    68
    I am trying the following section from the docs to reject my clinet's connection.

    https://docs-multiplayer.unity3d.co...etworkmanagerconnectionapprovalresponsereason

    I have used the same example script in the docs. My client indeed gets disconnected but DisconnectReason is always empty on the client. I have also tried using NetworkManager.Singleton.DisconnectClient(clientId, "reason"). The client gets disconnected but again, DisconnectReason is empty.

    Also, I am getting this error message after 10 seconds, which is the default Client Connection Buffer Timeout duration I guess.

    Code (CSharp):
    1. KeyNotFoundException: The given key '1' was not present in the dictionary.
    2. System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <d6232873609549b8a045fa15811a5bd3>:0)
    3. Unity.Netcode.NetworkManager.ClientIdToTransportId (System.UInt64 clientId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:1781)
    4. Unity.Netcode.NetworkManager.DisconnectRemoteClient (System.UInt64 clientId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:1361)
    5. Unity.Netcode.NetworkManager.DisconnectClient (System.UInt64 clientId, System.String reason) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:2063)
    6. Unity.Netcode.NetworkManager.DisconnectClient (System.UInt64 clientId) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:2038)
    7. Unity.Netcode.NetworkManager+<ApprovalTimeout>d__180.MoveNext () (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:1765)
    8. UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <bae255e3e08e46f7bc2fbd23dde96338>:0)
    Is there a way to finish the connection-approval to avoid getting this error?

    UPDATE: I am using Facepunch Transport and it looks like this is the cause. Unity Transport is working fine. Now, I need to find out why the Facepunch Transport not working.

    You can follow this topic from here as well:
    https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/2389
     
    Last edited: Mar 22, 2023