Search Unity

Error on re-joining a match with NetworkLobbyManager

Discussion in 'Multiplayer' started by Chris_Entropy, Oct 7, 2015.

  1. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Hi, I am using the standard NetworkLobbyManager, and I am getting this error:

    ArgumentException: An element with the same key already exists in the dictionary. System.Collections.Generic.Dictionary`2[UnityEngine.Networking.Types.NetworkID,UnityEngine.Networking.Types.NetworkAccessToken].Add (NetworkID key, UnityEngine.Networking.Types.NetworkAccessToken value) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:404) UnityEngine.Networking.Utility.SetAccessTokenForNetwork (NetworkID netId, UnityEngine.Networking.Types.NetworkAccessToken accessToken) (at C:/buildslave/unity/build/Runtime/Networking/Managed/UNETTypes.cs:119) UnityEngine.Networking.NetworkManager.OnMatchJoined (UnityEngine.Networking.Match.JoinMatchResponse matchInfo) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkManager.cs:1022) MenuWaitingForConnectingToMatch.OnMatchJoined (UnityEngine.Networking.Match.JoinMatchResponse response) (at Assets/scripts/menu/main menu/Network/MenuWaitingForConnectingToMatch.cs:58) UnityEngine.Networking.Match.NetworkMatch+<ProcessMatchResponse>c__Iterator0`1[UnityEngine.Networking.Match.JoinMatchResponse].MoveNext () (at C:/buildslave/unity/build/Runtime/Networking/Managed/MatchMakingClient.cs:302)

    Seems to be a known bug, that is officially marked as "resolved" (see bugtracker issue 708502). Will this be fixed in a future release or is the bug back? Should I open a new bugtracker for this issue?
     
  2. JeremyUnity

    JeremyUnity

    Joined:
    Mar 4, 2014
    Posts:
    147
    It's fixed in code not yet released.
     
  3. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Could you give me a rough estimate about when this will be released?
     
  4. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Days, weeks, months?
     
  5. nomenonX

    nomenonX

    Joined:
    Mar 17, 2015
    Posts:
    14
    5.2.2 same error
     
  6. nomenonX

    nomenonX

    Joined:
    Mar 17, 2015
    Posts:
    14
    anyone knows how to fix it?
     
  7. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Is this still not fixed in the newest 5.3 Unity build?

    There is a workaround in the thread for the Issue Tracker for this bug: http://issuetracker.unity3d.com/issues/matchmaker-cant-re-join-a-match-after-leaving

    You have to create a new class, that extends the NetworkLobbyManager class override its MatchJoined function:

    http://issuetracker.unity3d.com/issues/matchmaker-cant-re-join-a-match-after-leaving

    Code (CSharp):
    1.  
    2. public virtual void MatchJoined(JoinMatchResponse matchInfo)
    3. {
    4. if (LogFilter.logDebug)
    5. {
    6. Debug.Log("NetworkManager OnMatchJoined ");
    7. }
    8. if (matchInfo.success)
    9. {
    10. try
    11. {
    12. Utility.SetAccessTokenForNetwork(matchInfo.networkId, new NetworkAccessToken(matchInfo.accessTokenString));
    13. }
    14. catch(Exception ex)
    15. {
    16. if (LogFilter.logError)
    17. {
    18. Debug.LogError(ex);
    19. }
    20. }
    21. this.StartClient(new MatchInfo(matchInfo));
    22. }
    23. else if (LogFilter.logError)
    24. {
    25. Debug.LogError(string.Concat("Join Failed:", matchInfo));
    26. }
    27. }
    28.  
    This removed the bug for me, although I don't like to use workarounds. Why is this still an issue in 5.3, although it's officially fixed??
     
  8. nomenonX

    nomenonX

    Joined:
    Mar 17, 2015
    Posts:
    14
    host:
    1. Enable Match Maker
    2. Create Internet Match (default)
    client:
    1. Enable Match Maker
    2. Find Internet Match
    3. Join match default
    4. Stop
    5. Return to step 1-3.
    6. BOOM! Error

    The problem is repeated in NetworkLobbyManager & NetworkManager too

    video here:
     
  9. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Does this happen with the workaround I proposed?
     
  10. nomenonX

    nomenonX

    Joined:
    Mar 17, 2015
    Posts:
    14
    yes,I tried all options
     
  11. nomenonX

    nomenonX

    Joined:
    Mar 17, 2015
    Posts:
    14
    but the problem is in re-joining client to the server, creating a new Internet match had improved earlier.
     
  12. Chris_Entropy

    Chris_Entropy

    Joined:
    Apr 11, 2011
    Posts:
    202
    Then I will not be able to help you. Unity is up again for fixing this...
     
  13. nomenonX

    nomenonX

    Joined:
    Mar 17, 2015
    Posts:
    14
    problem solved. very strange)) if no change in the code (standart OnMatchJoined callback) - occurs error. if I use the proposed option - occurs error
    but if you comment out -
    // Utility.SetAccessTokenForNetwork(matchInfo.networkId, new NetworkAccessToken(matchInfo.accessTokenString));
    everything works well !

    Code (CSharp):
    1.     private void OnFindMatch(ListMatchResponse matchListResponse)
    2.     {
    3.         if (matchListResponse.success && matchListResponse.matches != null)
    4.         {
    5.             singleton.matchMaker.JoinMatch(matchListResponse.matches[0].networkId, "", OnMatchJoinedNew);
    6.         }
    7.     }
    8.     public void OnMatchJoinedNew(JoinMatchResponse matchInfo)
    9.     {
    10.         Debug.Log("NetworkManager OnMatchJoined ");
    11.         // Utility.SetAccessTokenForNetwork(matchInfo.networkId, new NetworkAccessToken(matchInfo.accessTokenString));
    12.         StartClient(new MatchInfo(matchInfo));
    13.     }
     
    Last edited: Dec 21, 2015