MatchMaker issues

While working with the MatchMaker (NetworkMatch), I’ve noticed a lot of issues creating and joining matches. Tested with both 5.1.1f1 and 5.1.1p1.

[A sample project is attached below, but all you need is a NetworkManager (or NetworkLobbyManager) and a NetworkManagerHUD. Don’t forget to set your Cloud Project ID in the Player Settings.]

Here are some test cases with 2 Clients:

a) Client 1 creates an internet match, stops the Match Maker, starts the Match Maker again, and creates a new, second internet match.

Error: host id out of bound id {-1} max id should be greater 0 and less than {1}
UnityEngine.Networking.Match.c__Iterator01:MoveNext()* *Error: Host doesn't exist* *UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator01:MoveNext()

The new match will be created regardless, but when Client 2 tries to join, he gets a timeout.

b) Client 1 creates an internet match, stops the Match Maker, starts the Match Maker again, goes to “Find Internet Match” and joins the match he just created.

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)

This probably happens due to the OnMatchJoined callback inside the JoinMatch() call, which always tries to set an access token.

c) Client 1 creates an internet match and leaves.
Client 2 finds that (now empty) match and tries to join. Result: Timeout.

Conclusion: Apparently, the ONLY way to get 2 Clients in the same match together is, if one client creates a match (without ever going back), and the other client joins (and also never goes back). If any involved client exits the lobby, they won’t be able to get together again. Unless they restart the game and start over.

Any info or suggestions are much appreciated.

2177924–144257–MatchMaker.zip (1.02 MB)

2 Likes

So what I gather is the old match never gets destroyed, in looking at what the NetworkManager does when you call StopMatchmaker it destroys the object but doesn’t call DestroyMatch so what will happen is it will create a match that is already created because the old one already exists.

I have not been able to get the DestroyMatch function to work properly at all. I have posted several times about it with no real information about how its suppose to work.

1 Like

Issue (a) has been fixed in 5.1.1p2 - Hooray.

Baby steps.

I just wrote a short post about matchmaking for anyone who’s still stuck or confused

So here is my issue, even in following that guide I get the following error on my android device when I try and create a match.

I have yet to figure out how to resolve this because its been a constant issue since day one. I am setting the AppId etc…

All I can say is matchmaking has some pretty serious issues that need to be addressed. I have an issue of my own now :frowning:

I’m testing on three instances: Unity editor, Mac native app, and Android app.
I can create a game and have another client join, no problem.
The issue arises when 1 instance hosts, another instance joins that host, and the last instance hosts. The third instance hosting gets the dreaded host id out of range bug.
I can restart the third instance to try again, use NetworkManagerHUD, etc, all lead to the same error.

This reminds me, even when all my clients have been shut down for a hours, when I look up my CCU usage, it always says 2/100.

If an engineer could help us out, I’ll update the guide with the new findings.

Also, what OnXXX function gets called on User2 when

User1 hosts
User2 joins User1’s match
User1 crashes shortly afterwards

I get the header warnings on User2 but I can’t find the function that gets called. I’d expect it to be OnClientError or OnClientDisconnect but those only get called after the game starts.

So I have figured out my issue, So I had the following code piece,

CreateMatchRequest create = new CreateMatchRequest();
create.name = SystemInfo.deviceName;
create.size = 3;
create.advertise = true;
create.password = "";

UnityMatchmaking.Instance.MasterServerConnection.CreateMatch(create, OnMatchCreate);

So SystemInfo.deviceName on most android devices comes back as “” this value causes issues with the CreateMatchRequest name field I am going to assume stuff is not escaped correctly when the web request is made. Once I provided a legit string I was able to create games on my device.

Filed bug 712934 on this

Any updates on B? Or how to fix it?
I am getting the exact same thing on 5.3.4

1 Like

This is a huge issue where the problem will be solved (???

Yes, this bug is still around now after nearly a year of reporting? Is this even possible?

1 Like

I’m seeing the same issue. I’m also seeing this, similar issue:

Player A creates game. Player B joins the game. I later call these:

            if (Network.connections.Length == 1)
            {
                Network.CloseConnection(Network.connections[0], true);
            }
            else
            {
                foreach (NetworkPlayer connection in Network.connections)
                {
                    Network.CloseConnection(connection, true);
                }
            }
            NetworkManager.singleton.StopClient();
            NetworkManager.singleton.StopHost();
            NetworkManager.singleton.StopMatchMaker();
            Network.Disconnect();
            SceneManager.LoadScene("main");

After the scene has reloaded Player A can create another game, and player B can join. Works as many times as I like. But if, instead, Player B tries to create a game, there’s this error:

EDIT:
Also, if Player A creates a game, but doesn’t wait for Player B to join, but resets by calling the above code, and then tries to create another game, I get the

error in

as well.

1 Like

I am still having this issue (B) in 5.3.5f1.