Network.Connect not connecting to host data or ip address

I tried using the code below to connect to the matchmaking server and then connect over to my computer. This works perfectly on a Lan connection (Specifically on the same computer) but on different networks it does not connect at all. However, I know that the matchmaking server is working because the room name is still correctly displayed, it just does not connect to the server. I get the error message: “Unable to connect to [ip address]…”. It is really weird because one: I know that my ip address is public and two: I tried connecting to the ip address with a forwarded port and that didnt work either. Im really confused…really I dont even need the matchmaking server and would prefer if I can just do portforward and it works…but no matter what I do it wont work. Can someone shine some light on this?

Thanks!

Master server code:


private HostData[] hostList;
private void StartServer()
{
    Network.InitializeServer(32, 25000, !Network.HavePublicAddress());
    MasterServer.RegisterHost("NEN Server", "Room 1");
}

private void RefreshHostList()
{
    MasterServer.RequestHostList("NEN Server");
}

void OnMasterServerEvent(MasterServerEvent msEvent)
{
    if (msEvent == MasterServerEvent.HostListReceived)
        hostList = MasterServer.PollHostList();
}
private void JoinServer(HostData hostData)
{
    Network.Connect(hostData);
}

void OnConnectedToServer()
{
    Debug.Log("Server Joined");
}

//the buttons
void OnGUI()
{
    if (!Network.isClient && !Network.isServer)
    {
        RefreshHostList();

        if (GUI.Button(new Rect(100, 50, 250, 100), "Start Server"))
            StartServer();
        

        if (hostList != null)
        {
            for (int i = 0; i < hostList.Length; i++)
            {
                if (GUI.Button(new Rect(400, 50 + (60 * i), 300, 100), hostList*.gameName))*

JoinServer(hostList*);*
}
}
}
}
void OnServerInitialized()
{
Debug.Log ("Ip address: " + Network.player.ipAddress);
Debug.Log("External ip: " + Network.player.externalIP);

Debug.Log (“server initialized”);
}
----------

I am not good with C# at all, but i think i now what the problem is.
In line 20 where you are trying to connect you are connecting to an to hostdata thats inside of an array and you have not defined the index of the array your trying to connect to.

Again i am not good with C# and i am not shure if this will work but thats what i can understand from your code and the error that it is giving.