When I try to connect to a match, it says Failed to connect to master server at 67.225.180.24:23466
I am doing this with 2 clients of the game open.
How can I get it working?
I followed this tutorial on how to set up the master server: http://www.youtube.com/watch?v=1KIoGOYOUvk
I used these 2 scripts for the network and menu:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class NetworkManager : MonoBehaviour {
public string PlayerName;
public string MatchName;
public static NetworkManager Instance;
public List<Player> PlayerList = new List<Player>();
// Use this for initialization
void Start () {
Instance = this;
DontDestroyOnLoad(gameObject);
}
// Update is called once per frame
void Update () {
}
public void StartServer(string ServerName, int MaxPlayers){
Network.InitializeSecurity();
Network.InitializeServer(MaxPlayers,23466,true);
MasterServer.RegisterHost("Tut",ServerName,"");
Debug.Log ("Started Server");
}
}
[System.Serializable]
public class Player{
public string PlayerName;
}
using UnityEngine;
using System.Collections;
public class Menu : MonoBehaviour {
private string CurMenu;
public string Name;
public string MatchName;
public int Players;
// Use this for initialization
void Start () {
CurMenu = "Main";
Name = PlayerPrefs.GetString("PlayerName");
}
// Update is called once per frame
void Update () {
}
void ToMenu(string menu){
CurMenu = menu;
}
void OnGUI(){
if(CurMenu == "Main")
Main();
if(CurMenu == "Host")
Host();
if(CurMenu == "Lobby")
Lobby();
if(CurMenu == "List")
MatchList();
}
private void Main(){
if(GUI.Button(new Rect(0, 0, 128, 32),"Host a Match")){
ToMenu("Host");
}
Name = GUI.TextField(new Rect(130, 0, 128, 32),Name);
if(GUI.Button(new Rect(260, 0, 128, 32),"Save")){
PlayerPrefs.SetString("PlayerName",Name);
}
if(GUI.Button(new Rect(0, 33, 128, 32),"Server List")){
ToMenu("List");
}
}
private void Host(){
if(GUI.Button(new Rect(0, 0, 128, 32),"Start")){
NetworkManager.Instance.StartServer(MatchName,Players);
ToMenu("Lobby");
}
if(GUI.Button(new Rect(0, 845, 128, 32),"Back")){
ToMenu("Main");
}
MatchName = GUI.TextField(new Rect(130, 0, 128, 32),MatchName);
GUI.Label(new Rect(260, 0, 128, 32),"Match Name");
Players = Mathf.Clamp(Players, 0, 32);
GUI.Label(new Rect(115, 33, 128, 32),"Max Players");
if(GUI.Button(new Rect(192, 33, 32, 32),"+"))
Players ++;
GUI.Label(new Rect(232, 33, 64, 32),Players.ToString());
if(GUI.Button(new Rect(252, 33, 32, 32),"-"))
Players --;
}
private void Lobby(){
if(GUI.Button(new Rect(Screen.width - 128, Screen.height - 64, 128, 32),"Start")){
}
if(GUI.Button(new Rect(Screen.width - 128, Screen.height - 32, 128, 32),"Back")){
ToMenu("Host");
}
}
private void MatchList(){
if(GUI.Button(new Rect(0, 410, 128, 32),"Refresh")){
MasterServer.RequestHostList("Tut");
}
if(GUI.Button(new Rect(0, 445, 128, 32),"Back")){
ToMenu("Main");
}
GUILayout.BeginArea(new Rect(Screen.width/2, 0, Screen.width/2, Screen.height),"Server List","box");
foreach(HostData hd in MasterServer.PollHostList()){
GUILayout.BeginHorizontal();
GUILayout.Label(hd.gameName);
if(GUILayout.Button("Connect")){
Network.Connect(hd);
ToMenu("Lobby");
}
GUILayout.EndHorizontal();
}
GUILayout.EndArea();
}
}