MatchMaker issue : Working from the same PC, not working from different PC ?!?

HI all.

While pulling my hair trying to make this all work , i just found out something… weird ?

Basically, from the same pc, i can launch two different client, start matchmaker, create a match, the second build joins it , all good.

When i try from two differrent PC : I am getting Timeouts from the client… it sees the match, try to connect to the host, timeouts.

Any idea ? Before i give up and simply try another network solution ?

SO i have put the network manager to Developer Output. And this is what i get :

Client Relay Slot Id: -1
UnityEngine.Networking.NetworkClient:Connect(MatchInfo)
ManNetwork:MatchJoined(JoinMatchResponse) (at Assets/XLink Assets/Scripts/Network/ManNetwork.cs:102)
UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator0`1:MoveNext()

Client event: host=0 event=DisconnectEvent error=6
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

Client disconnected
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

And then a big " Client Disconnect" …

Coud still use some help, please…

Alright… I could seriously use some help here…

I managed to narrowed it down a little bit …

The connection between the two PC works when i am using the NetworkManagedHud component, with the runtime GUI.
But when i try my own Match Script, that s when it fails. And something is missing when i do it with my script.
So : This is a screen of both the HUDs :

And here is my code :

void Start ()
    {
        StartMatchMaker() ;
        networkMatch = GetComponent<NetworkMatch>();
        UnityEngine.Networking.Types.AppID appid = (UnityEngine.Networking.Types.AppID)41551;
        networkMatch.SetProgramAppID(appid);  
    }

    //Start the 1v1 Matcher
    public void Start1V1 ()
    {
        networkMatch.ListMatches(0, 20, "", ListMatch);   
    }

    public void ListMatch(ListMatchResponse matchListResponse)
    {
        if (matchListResponse.success && matchListResponse.matches != null)
        {
            matchList = matchListResponse.matches ;
            matchCount = matchList.Count ;

            //No Match Found
            if (matchList.Count == 0)
            {
                CreateMatch() ;
            }
            else
            {
                FindAMatch () ;
            }           
        }
    }

    public void CreateMatch ()
    {
        CreateMatchRequest create = new CreateMatchRequest();
        create.name = "TestMatch" ;
        create.size = 2 ;
        create.advertise = true ;
        create.password = "" ;
        networkMatch.CreateMatch(create, MatchCreated);
    }

    public void MatchCreated (CreateMatchResponse matchResponse)
    {
        if (matchResponse.success)
        {
            matchCreated = true ;
            Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));
            NetworkServer.Listen(new MatchInfo(matchResponse), 9000);
            Start1V1AsHost() ;
        }
        else
        {
            print ("Failed during Match Creation") ;
        }  
    }

    public void FindAMatch()
    {
        networkMatch.JoinMatch(matchList[0].networkId, "", MatchJoined);
    }

    public void MatchJoined (JoinMatchResponse matchJoin)
    {
        if (matchJoin.success)
        {
            matchJoined = true ;  
            Utility.SetAccessTokenForNetwork(matchJoin.networkId, new NetworkAccessToken(matchJoin.accessTokenString));
            NetworkClient myClient = new NetworkClient();
            myClient.RegisterHandler(MsgType.Connect, OnConnected);
            myClient.Connect(new MatchInfo(matchJoin)); 
        }
        else
        {
            print("Failed to Join Match") ;
        }  
    }

    public void OnConnected(NetworkMessage msg)
    {
        StartClient() ;  
    }

    public void Start1V1AsHost ()
    {
        StartHost() ;
        controller.hosting = true ;
        controller.StartCoroutine("Start1V1") ;   
    }

    //When Player Prefab gets Created
    public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId)
    {
        controller.playersInGame ++ ;
        var player = (GameObject)GameObject.Instantiate(playerPrefab, new Vector3(0,0,0) , Quaternion.identity);
        if (controller.playersInGame == 1) { player.GetComponent<NetPlayer>().team = 1 ; }
        if (controller.playersInGame == 2) { player.GetComponent<NetPlayer>().team = 2 ; }
        NetworkServer.AddPlayerForConnection(conn, player, playerControllerId);
    }

I am getting desperate here…

1 Like

Found it…

modified for :

matchInfo = new MatchInfo(matchResponse);
Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));
StartHost(matchInfo) ;

and :

matchJoined = true ;
matchInfo = new MatchInfo(matchJoin);
Utility.SetAccessTokenForNetwork(matchJoin.networkId, new NetworkAccessToken(matchJoin.accessTokenString));;
StartClient(matchInfo) ;

Thanks JetBrains.dotPeek

4 Likes

Please report this as a bug (pretty sure it is).

On Unity 5.2.0f3 and I had this exact same problem, and was able to resolve with what you put in your post. You saved me a lot of headache, so thank you!

Thank you Feydwin ! saved me lot of time