Client won't connect to a host using matchmaking

I have been working on creating a multiplayer arcade shooter using UNET and the LAN networking is working well, and recently I moved to attempt matchmaking. The big problem I’ve had recently however is that unless the network address is localhost, and the host is on the same computer, the client wont connect. If the network address is set to anything else, even if the host is still on the same computer, the client will be able to see the game room, but when attempting to join the game, the client wont start (also the client refuses to start if matchinfo is passed through StartClient).

I have made sure to check that the UPID is correct, and I’m passing through the UNET ID using the setProgramAppID for matchmaker, as well as other solutions from threads I have seen littered across forums, but still to no avail. Has anyone run into this problem themselves, or would know of why this may be happening?

This is my code for the custom HUD in case it would help to review it for the problem.Code

#if ENABLE_UNET

namespace UnityEngine.Networking
{
    using UnityEngine.UI;
    using UnityEngine.SceneManagement;
    using System.Collections.Generic;
    using System.Collections;
    using System;
    using UnityEngine.Networking.Types;
    using UnityEngine.Networking.Match;
    using UnityEngine.EventSystems;
    [AddComponentMenu("Network/NetworkManagerHUD")]
    [RequireComponent(typeof(NetworkManager))]
    [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
    public class NetworkManagerUI : NetworkBehaviour
    {
        public NetworkManager manager;
        [SerializeField]
        public bool showGUI = true;
        [SerializeField]
        public int offsetX;
        [SerializeField]
        public int offsetY;

        public Canvas networkConfigCanvas;

        public InputField playerName;

        public InputField ipAddress;

        public Text noPlayerName;

        public Text noIP;

        public GameObject connectingPanel;

        public GameObject configPanel;

        public Text attemptingConnect;

        public GameObject panelToToggleActive;

        public GameObject pausePanel;

        public GameObject leaderboardPanel;

        public string chosenPlayerName;

        public Text playerHeading;

        public Text killHeading;

        public Text deathHeading;

        public Text whoWon;

        Text winner;

        ArrayList playerKills = new ArrayList(); //GUI text

        ArrayList playerDeaths = new ArrayList(); //GUI text

        ArrayList playersInGame = new ArrayList(); // GUI text componenets

        [SyncVar]
        public ArrayList playerNames = new ArrayList(); // Actual Names

        [SyncVar]
        ArrayList playerNetIDs = new ArrayList();

        [SyncVar]
        public int gameTime = 600;

        [SyncVar]
        public int originalGameTime = 600;

        public Text gameTimerText;

        NetworkViewID localPlayer;

        bool ending = false;

        ArrayList scores = new ArrayList();

        // Runtime variable
        bool showServer = false;

        List<MatchDesc> matchList = new List<MatchDesc>();

        bool matchCreated;

        NetworkMatch networkMatch;

        public GameObject roomListPanel;

        public GameObject contentToScroll;

        public GameObject RoomDescription;

        ArrayList roomDescriptionClones = new ArrayList();

        bool listRoomsBool = false;

        long m_networkId;

        long m_nodeId;

        void Awake()
        {
            originalGameTime *= 60;
            gameTime = originalGameTime;
            leaderboardPanel.SetActive(false);
            pausePanel.SetActive(false);
            noPlayerName.enabled = false;
            noIP.enabled = false;
            connectingPanel.SetActive(false);
            manager = gameObject.GetComponent<NetworkManager>();
            PlayerPrefs.SetString("CloudNetworkingId", "1093751");
            manager.StartMatchMaker();
            manager.matchMaker.SetProgramAppID((AppID)1093751);
        }

        public void createRoom()
        {
            if (manager.matchMaker == null)
            {
                manager.StartMatchMaker();
                manager.matchMaker.SetProgramAppID((AppID)1093751);
            }
            if (playerName.text != "")
            {
                CreateMatchRequest create = new CreateMatchRequest();
                create.name = playerName.text;
                create.size = 10;
                create.advertise = true;
                create.password = "";

                manager.matchMaker.CreateMatch(create, OnMatchCreate);
            }
            else
            {
                noPlayerName.enabled = true;
            }
        }

        public void listRooms()
        {
            if (manager.matchMaker == null)
            {
                manager.StartMatchMaker();
                manager.matchMaker.SetProgramAppID((AppID)1093751);
            }
            if (playerName.text != "")
            {
                noPlayerName.enabled = false;
                chosenPlayerName = playerName.text;
                manager.matchMaker.ListMatches(0, 20, "", OnMatchList);
            }
            else
            {
                noPlayerName.enabled = true;
            }
        }

        public void OnMatchCreate(CreateMatchResponse matchResponse)
        {
            if (matchResponse.success)
            {
                Debug.Log("Create match succeeded");
                matchCreated = true;
                Utility.SetAccessTokenForNetwork(matchResponse.networkId, new NetworkAccessToken(matchResponse.accessTokenString));
                NetworkServer.Listen(new MatchInfo(matchResponse), 9000);
                manager.matchInfo = new MatchInfo(matchResponse);
                startHost();
            }
            else
            {
                Debug.LogError("Create match failed");
            }
        }

        public void joinMatch()
        {
            listRoomsBool = false;
            manager = GameObject.Find("NetworkManager").GetComponent<NetworkManager>();
            manager.StartMatchMaker();
            manager.matchMaker.SetProgramAppID((AppID)1093751);
            manager.matchMaker.ListMatches(0, 20, "", OnMatchPopulate);
        }

        public void OnMatchPopulate(ListMatchResponse matchListResponse)
        {
            manager = GameObject.Find("NetworkManager").GetComponent<NetworkManager>();
            GameObject roomDesc = EventSystem.current.currentSelectedGameObject;
            manager.matchMaker.JoinMatch(matchListResponse.matches[int.Parse(roomDesc.transform.parent.name.Substring(4))].networkId, "", OnMatchJoined);
        }

        public void OnMatchList(ListMatchResponse matchListResponse)
        {
            if (matchListResponse.success && matchListResponse.matches != null)
            {
                for (int i = 0; i < roomDescriptionClones.Count; i++)
                {
                    GameObject.Destroy((GameObject)roomDescriptionClones[i]);
                }
                listRoomsBool = true;
                for (int i = 0; i < matchListResponse.matches.Count; i++)
                {
                    GameObject roomDescriptionClone = (GameObject)Instantiate(RoomDescription, new Vector3(0, 0, 0), (RoomDescription.GetComponent<Transform>().rotation));
                    roomDescriptionClone.transform.SetParent(contentToScroll.transform);
                    roomDescriptionClone.GetComponent<RectTransform>().localPosition = new Vector3(0, 180 - i * 75, 0);
                    roomDescriptionClone.name = "Room" + i;
                    roomDescriptionClone.transform.Find("RoomName").GetComponent<Text>().text = "Room Name: " + matchListResponse.matches[i].name;
                    roomDescriptionClone.transform.Find("RoomSize").GetComponent<Text>().text = "Room Size: " + matchListResponse.matches[i].currentSize + "/" + matchListResponse.matches[i].maxSize;
                    roomDescriptionClones.Add(roomDescriptionClone);
                    matchList.Add(matchListResponse.matches[i]);
                }
            }
        }

        public void OnMatchJoined(JoinMatchResponse matchJoin)
        {
            if (matchJoin.success)
            {
                Debug.Log("Join match succeeded");
                if (matchCreated)
                {
                    Debug.LogWarning("Match already set up, aborting...");
                    return;
                }
                try
                {
                    Utility.SetAccessTokenForNetwork(matchJoin.networkId, new NetworkAccessToken(matchJoin.accessTokenString));
                }
                catch (Exception ex)
                {
                    if (LogFilter.logError)
                    {
                        //Debug.LogError(ex);
                    }
                }
                NetworkClient myClient = new NetworkClient();
                myClient.RegisterHandler(MsgType.Connect, OnConnected);
                myClient.Connect(new MatchInfo(matchJoin));
                m_networkId = (long)matchJoin.networkId;
                m_nodeId = (long)matchJoin.nodeId;
                manager.networkAddress = matchJoin.address;
                manager.networkPort = matchJoin.port;
                manager.matchInfo = new MatchInfo(matchJoin);
                manager.StartClient();
                print(manager.networkAddress);
            }
            else
            {
                Debug.LogError("Join match failed");
            }
        }

        public void OnConnected(NetworkMessage msg)
        {
            Debug.Log("Connected!");
        }

        public void updateGameTime(int playerGameTime)
        {
            gameTime = playerGameTime;
        }

        void Update()
        {
            if (manager.IsClientConnected())
            {
                print("hello");
            }
            if ((gameTime % 3600) / 60 > 9)
                gameTimerText.text = gameTime / 3600 + ":" + (gameTime % 3600) / 60;
            else
                gameTimerText.text = gameTime / 3600 + ":0" + (gameTime % 3600) / 60;

            if (gameTime <= 0)
            {
                scores.Clear();
                ending = true;
                if (winner != null)
                    Destroy(winner.gameObject);
                winner = (Text)Instantiate(whoWon, whoWon.transform.position, whoWon.transform.rotation);
                winner.enabled = true;
                winner.gameObject.SetActive(true);
                winner.transform.SetParent(whoWon.transform.parent);
                try {
                    for (int i = 0; i < playerKills.Count; i++)
                    {
                        ((Text)playerDeaths[i]).text = (ClientScene.FindLocalObject((NetworkInstanceId)playerNetIDs[i]).GetComponent<PlayerSetup>().deaths).ToString();
                        ((Text)playerKills[i]).text = (ClientScene.FindLocalObject((NetworkInstanceId)playerNetIDs[i]).GetComponent<PlayerSetup>().kills).ToString();
                        scores.Add(int.Parse(((Text)playerKills[i]).text) - int.Parse(((Text)playerDeaths[i]).text));
                    }
                } catch (Exception e)
                {
                     disconnect();
                }
                int indexOfWinner = 0;
                for (int i = 0; i < scores.Count; i++)
                {
                    if ((int)scores[i] > (int)scores[indexOfWinner])
                    {
                        indexOfWinner = i;
                    }
                }
                winner.text = (string)playerNames[indexOfWinner] + " has won with a score of " + ((Text)playerKills[indexOfWinner]).text + " kills and " + ((Text)playerDeaths[indexOfWinner]).text + " deaths";
                if (gameTime < -180)
                {
                    disconnect();
                }
            }

            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            if (players.Length != playerNames.Count)
            {
                playerNames.Clear();
                playerNetIDs.Clear();
                for (int i = 0; i < playersInGame.Count; i++)
                {
                    Destroy((Text)playersInGame[i]);
                    Destroy((Text)playerDeaths[i]);
                    Destroy((Text)playerKills[i]);
                }
                playerDeaths.Clear();
                playerKills.Clear();
                playersInGame.Clear();
                for (int i = 0; i < players.Length; i++)
                {
                    if (players[i].GetComponent<PlayerSetup>().playerName != "")
                    {
                        playerNames.Add(players[i].GetComponent<PlayerSetup>().playerName);
                        playerNetIDs.Add(players[i].GetComponent<NetworkIdentity>().netId);
                        print(playerNames[i]);
                        playersInGame.Add((Text)Instantiate(playerHeading, new Vector3(playerHeading.transform.position.x, playerHeading.transform.position.y + (i + 1) * -35, 0), playerHeading.transform.rotation));
                        ((Text)playersInGame[i]).transform.SetParent(leaderboardPanel.transform);
                        ((Text)playersInGame[i]).text = (string)playerNames[i];
                        playerKills.Add((Text)Instantiate(killHeading, new Vector3(killHeading.transform.position.x, killHeading.transform.position.y + (i + 1) * -35, 0), killHeading.transform.rotation));
                        ((Text)playerKills[i]).transform.SetParent(leaderboardPanel.transform);
                        ((Text)playerKills[i]).text = (ClientScene.FindLocalObject((NetworkInstanceId)playerNetIDs[i]).GetComponent<PlayerSetup>().kills).ToString();
                        playerDeaths.Add((Text)Instantiate(deathHeading, new Vector3(deathHeading.transform.position.x, deathHeading.transform.position.y + (i + 1) * -35, 0), deathHeading.transform.rotation));
                        ((Text)playerDeaths[i]).transform.SetParent(leaderboardPanel.transform);
                        ((Text)playerDeaths[i]).text = (ClientScene.FindLocalObject((NetworkInstanceId)playerNetIDs[i]).GetComponent<PlayerSetup>().deaths).ToString();
                    }
                }
            }

            if (!showGUI)
                return;

            if (Input.GetButtonDown("Pause") && ((NetworkClient.active && manager.IsClientConnected()) || NetworkServer.active /*manager.matchMaker != null*/) && !ending)
            {
                pausePanel.SetActive(!pausePanel.activeSelf);
            }

            if (Input.GetButton("Leaderboards") && ((NetworkClient.active && manager.IsClientConnected()) || NetworkServer.active /*manager.matchMaker != null*/) && !ending)
            {
                for (int i = 0; i < playerKills.Count; i++)
                {
                    ((Text)playerDeaths[i]).text = (ClientScene.FindLocalObject((NetworkInstanceId)playerNetIDs[i]).GetComponent<PlayerSetup>().deaths).ToString();
                    ((Text)playerKills[i]).text = (ClientScene.FindLocalObject((NetworkInstanceId)playerNetIDs[i]).GetComponent<PlayerSetup>().kills).ToString();
                }
                leaderboardPanel.SetActive(true);
            }
            else
            {
                leaderboardPanel.SetActive(false);
            }

            if (!NetworkClient.active && !NetworkServer.active/*manager.matchMaker == null*/)
            {
                if (winner != null)
                    Destroy(winner.gameObject);
                ending = false;
                gameTime = originalGameTime;
                if (playerNames.Count > 0)
                {
                    playerNames.Clear();
                    for (int i = 0; i < playersInGame.Count; i++)
                    {
                        Destroy((Text)playersInGame[i]);
                        Destroy((Text)playerDeaths[i]);
                        Destroy((Text)playerKills[i]);
                    }
                    playerDeaths.Clear();
                    playerKills.Clear();
                    playersInGame.Clear();
                }
                leaderboardPanel.SetActive(false);
                pausePanel.SetActive(false);
                panelToToggleActive.SetActive(true);
                if (!listRoomsBool)
                {
                    configPanel.SetActive(true);
                    connectingPanel.SetActive(false);
                    roomListPanel.SetActive(false);
                }
                else
                {
                    configPanel.SetActive(false);
                    connectingPanel.SetActive(false);
                    roomListPanel.SetActive(true);
                }
            }
           
            if ((NetworkClient.active && manager.IsClientConnected()) || NetworkServer.active /*manager.matchMaker != null*/)
            {
                panelToToggleActive.SetActive(false);
            }
            else
            {
                panelToToggleActive.SetActive(true);
            }

            /*if (!manager.IsClientConnected() && NetworkClient.active)
            {
                connectingPanel.SetActive(true);
                configPanel.SetActive(false);
                roomListPanel.SetActive(false);
                listRoomsBool = false;
            }*/
        }

        public void backFromRoomList()
        {
            listRoomsBool = false;
        }

        public void refreshRoomList()
        {
            manager.matchMaker.ListMatches(0, 20, "", OnMatchList);
        }

        private void OnDestroyMatch(BasicResponse response)
        {
            throw new NotImplementedException();
        }

        private void OnConnectionDrop(BasicResponse response)
        {
            throw new NotImplementedException();
        }

        public void closePauseScreen()
        {
            pausePanel.SetActive(false);
        }

        public void disconnectFromMatch()
        {
            manager = GameObject.Find("NetworkManager").GetComponent<NetworkManager>();
            manager.StartMatchMaker();
            manager.matchMaker.SetProgramAppID((AppID)1093751); if (NetworkServer.active)
            {
                this.manager.matchMaker.DestroyMatch(manager.matchInfo.networkId, OnDestroyMatch);
            }
            if (NetworkClient.active)
            {
                DropConnectionRequest dropReq = new DropConnectionRequest();
                dropReq.networkId = (NetworkID)m_networkId;
                dropReq.nodeId = (NodeID)m_nodeId;
                this.manager.matchMaker.DropConnection(dropReq, OnConnectionDrop);
                manager.client.Disconnect();
            }
            listRoomsBool = false;
        }

        public void disconnect()
        {
            manager.GetComponent<NetworkManagerUI>().disconnectFromMatch();
            manager.StopHost();
            manager.StopMatchMaker();
            pausePanel.SetActive(false);
        }

        public void exitToMainMenu()
        {
            SceneManager.LoadScene("MainMenu");
        }

        public void exitGame()
        {
            Application.Quit();
        }

        public void cancelConnect()
        {
            manager.StopClient();
            configPanel.SetActive(true);
            connectingPanel.SetActive(false);
        }

        public void startHost()
        {
            noPlayerName.enabled = false;
            noIP.enabled = false;
            if (playerName.text != "")
            {
                chosenPlayerName = playerName.text;
                //playerNames.Add(chosenPlayerName);
                manager.StartHost();
            }
            else
            {
                noPlayerName.enabled = true;
            }
        }

        public void startClient()
        {
            noPlayerName.enabled = false;
            noIP.enabled = false;
            if (ipAddress.text != "" && playerName.text != "")
            {
                chosenPlayerName = playerName.text;
                //playerNames.Add(chosenPlayerName);
                manager.networkAddress = ipAddress.text;
                manager.StartClient();
            }
            if (ipAddress.text == "")
            {
                noIP.enabled = true;
            }
            if (playerName.text == "")
            {
                noPlayerName.enabled = true;
            }
        }

        public void backToMainMenu()
        {
            SceneManager.LoadScene("MainMenu");
            Destroy(manager.gameObject);
        }
    }
};
#endif //ENABLE_UNET

You could check out this lobby asset by Unity Technologies to see how they did it.