Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question NGO + Facepunch - Problem when approval is refused for a client

Discussion in 'Multiplayer' started by Goreduc, Dec 7, 2023.

  1. Goreduc

    Goreduc

    Joined:
    Jun 26, 2020
    Posts:
    9
    Hello,
    Don't know where to post, between NGO & Facepunch. Seems to have a conflict at early client's disconnection.
    Simple case :
    - Host is started
    - A client try to connect
    - Connexion approval is called on host side.
    - I decide to refuse the connexion
    - Then both the client and the host are disconnected...

    The main log :
    After putting a breakpoint on the warning raised by NGO, I discovered that
    Code (csharp):
    1. Unity.Netcode.NetworkConnectionManager.TransportIdCleanUp
    was called 2 times
    The first time, all is going fine :
    upload_2023-12-7_16-37-21.png

    The second time, the client is already removed from the TransportIdToClientIdMap and ClientIdToTransportIdMap, the warning is raised, and the function return (ulong)default = 0. This provoque the removal of Host's player object, and raise client disconnect events for client "0"
    upload_2023-12-7_16-37-55.png

    Thanks for any help !
     
  2. Casual909

    Casual909

    Joined:
    Mar 3, 2021
    Posts:
    12
    Got the same issue!
     
  3. Casual909

    Casual909

    Joined:
    Mar 3, 2021
    Posts:
    12
    Dirty fix: copy paste these cache package files to your package folder. Then turn return default into a high number. Not pretty but it works.

    Code (CSharp):
    1. [MethodImpl(MethodImplOptions.AggressiveInlining)]
    2. internal ulong TransportIdToClientId(ulong transportId)
    3. {
    4.     if (transportId == GetServerTransportId())
    5.     {
    6.         return NetworkManager.ServerClientId;
    7.     }
    8.  
    9.     if (TransportIdToClientIdMap.TryGetValue(transportId, out var clientId))
    10.     {
    11.         return clientId;
    12.     }
    13.  
    14.     if (NetworkLog.CurrentLogLevel == LogLevel.Developer)
    15.     {
    16.         NetworkLog.LogWarning($"Trying to get the NGO client ID map for the transport ID ({transportId}) but did not find the map entry! Returning default transport ID value.");
    17.     }
    18.  
    19.     return 9999;
    20. }
     
    Mr-Levich and Goreduc like this.
  4. Angels_Gaming

    Angels_Gaming

    Joined:
    Jun 1, 2022
    Posts:
    1
    how do you past it in the file without it beeing rewrite
     
  5. Goreduc

    Goreduc

    Joined:
    Jun 26, 2020
    Posts:
    9
    Thanks a lot ! :)
    Dirty but it works fine, and I didn't detect any side effect for now.

    But I got the same question as Angels_Gaming.
    For the moment I directly modified NetworkConnectionManager.cs and I made the job.
    But I suppose I will loose the modification if the package cache is refreshed

    When you say
    Can you give more details please ?
     
  6. Goreduc

    Goreduc

    Joined:
    Jun 26, 2020
    Posts:
    9
    Hello
    Still reproductible with Netcode for GameObjects v1.8.1
    @Netcode dev team : could you please fix this problem ?
    You have well identified the case, you detect it (the warning is raised), but the decision to return "the default transport ID value" (= the server) is really bad. In which case we would want to apply to the server an event addressed to a client no more existing ?
     
    Last edited: Feb 17, 2024 at 5:08 PM