I’m trying to understand how to set up my own master server. So far when I set this all up, I’m able to connect over my LAN, using my private IP. My issue is NAT. I’m trying to use the Facilitator so I can connect to my master server from outside my network/LAN.
Currently my internet is connected through a modem/router mix. I have ports 23465 - 23467 open and 50004 - 50006 open.
I’ve downloaded the MasterServer and Facilitator packets from Untiy and compiled them with Visual Studio 2012.
Keep in mind that these examples is me just trying to get two machines connected.
To start off, I launch the MasterServer.exe (Release) Then run my game as a host. Below is the code for the host.
function Start()
{
StartServer();
}
function StartServer()
{
MasterServer.ipAddress = "<My private IP";
Network.InitializeServer(10,25005,!Network.HavePublicAddressI());
MasterServer.RegisterHost("gameName","Game","comment");
}
function OnServerInitialized()
{
//Enables a new script with a bunch of GUI
}
Once this code makes its run, I can clearly see that the MasterServer command prompt has made the necessary rows for the game.
Then I run the client code which is below.
function Awake()
{
MasterServer.ipAddress = "<The IP of the Host Machine>";
MasterServer.RequestHostList("gameName");
}
function OnGUI()
{
var host: HostData[] = MasterServer.PollHostList();
for (var join in host)
{
GUI.Label(Rect(10,10,1000,25),"Server: ",+join.gameName+" is ready");
if(GUI.Button(Rect(10,40,75,25),"Connect"))
{
Network.Connect(join);
}
}
}
function OnConnectedToServer()
{
//Enables another scrip to display some GUI
}
So the above works fine. I’m able to connect to the MasterServer on my host machine over my network. (Private IP)
My issue is how do I set it up to run the Facilitator? Right now I’m starting with keeping the host code the same as it is because I’ve read that HostData[ ] holds all the nat, ip, port info. The client code I’m adding Network.natFacilitatorIP = “” and Network.natFacilitatorPort = #### above the MasterServer.ipAddress code.
I’m also running both the MasterServer.exe and the Facilitator.exe. (Both Release) And triple checking that my client machine is not on the same network.
function Awake()
{
Network.natFacilitatorIP = "<The PUBLIC IP address to my modem>";
Network.natFacilitatorPort = <The default 50005 when starting the Facilitator.exe>";
MasterServer.ipAddress....
.....
}
What am I missing and need to add so I’ll be able to connect from outside my network?
Does the host code need to have the natIP and natPort set to? I’ve tried but could possibly be doing it incorrectly.