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.Dictionary2[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__Iterator01[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?
It’s fixed in code not yet released.
Could you give me a rough estimate about when this will be released?
anyone knows how to fix it?
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: Unity Issue Tracker - [MatchMaker] Can't re-join a match after leaving
You have to create a new class, that extends the NetworkLobbyManager class override its MatchJoined function:
public virtual void MatchJoined(JoinMatchResponse matchInfo)
{
if (LogFilter.logDebug)
{
Debug.Log("NetworkManager OnMatchJoined ");
}
if (matchInfo.success)
{
try
{
Utility.SetAccessTokenForNetwork(matchInfo.networkId, new NetworkAccessToken(matchInfo.accessTokenString));
}
catch(Exception ex)
{
if (LogFilter.logError)
{
Debug.LogError(ex);
}
}
this.StartClient(new MatchInfo(matchInfo));
}
else if (LogFilter.logError)
{
Debug.LogError(string.Concat("Join Failed:", matchInfo));
}
}
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??
host:
- Enable Match Maker
- Create Internet Match (default)
client:
- Enable Match Maker
- Find Internet Match
- Join match default
- Stop
- Return to step 1-3.
- BOOM! Error
The problem is repeated in NetworkLobbyManager & NetworkManager too
video here:
Does this happen with the workaround I proposed?
but the problem is in re-joining client to the server, creating a new Internet match had improved earlier.
Then I will not be able to help you. Unity is up again for fixing this…
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 !
private void OnFindMatch(ListMatchResponse matchListResponse)
{
if (matchListResponse.success && matchListResponse.matches != null)
{
singleton.matchMaker.JoinMatch(matchListResponse.matches[0].networkId, "", OnMatchJoinedNew);
}
}
public void OnMatchJoinedNew(JoinMatchResponse matchInfo)
{
Debug.Log("NetworkManager OnMatchJoined ");
// Utility.SetAccessTokenForNetwork(matchInfo.networkId, new NetworkAccessToken(matchInfo.accessTokenString));
StartClient(new MatchInfo(matchInfo));
}