NetworkMatch.DestoryMatch causes missing reference exception on NetworkMatch

I can create matches just fine and clients can join and play a match together.
If I want to host a match and then cancel that match I’ll call DestoryMatch, which doesn’t throw any errors itself, but then if I call CreateMatch again I get a missing reference error:

I’m pretty sure this shouldn’t be happening, how else are we supposed to create matches after destroying one?

Bump.

After DestroyMatch is called the matchMaker object will clean itself up. Create a new matchmaking object and you won’t get nullrefs.

Edit: Matchmaking - DestroyMatch Does Not Do Anything - Unity Engine - Unity Discussions Unity says to use DropMatch instead of Destroy. :slight_smile:

1 Like

Thanks! I’d been top that thread but before the latest posts, will try that all today :slight_smile:

Edit:

Same issue with DropConnection. See below I simply swapped it in for DestroyMatch.

    public void DestroyMatch()
    {
        networkMatch.DropConnection(matchInfo.networkId, matchInfo.nodeId, OnMatchDestroyed);
//        networkMatch.DestroyMatch(matchInfo.networkId, OnMatchDestroyed);
    }
 
    public void OnMatchDestroyed(BasicResponse destroyMatchResponse)
    {
        Debug.Log("Cancel success: " + destroyMatchResponse.success);
    }

The call back is never called and networkMatch becomes null so I still get a missing reference exception when trying to host another match.

Also see my older thread: http://forum.unity3d.com/threads/how-to-use-networkmatch-properly.355254/

Here you can see that creating a new matchmaking object has its own issue. I’ve also tried calling StopMatchmaker on the NetworkManager object and then StartMatchmaker but I get the same issue:

host id out of bound id {-1} max id should be greater 0 and less than {2}
UnityEngine.Networking.NetworkServer:Listen(MatchInfo, Int32)
NetManagerHud:MatchCreated(CreateMatchResponse) (at Assets/Scripts/Networking/NetManagerHud.cs:78)
UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator0`1:MoveNext()