Search Unity

Person Master Server Help....

Discussion in 'Multiplayer' started by tecra134, Jan 9, 2013.

  1. tecra134

    tecra134

    Joined:
    Mar 19, 2011
    Posts:
    94
    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.

    Code (csharp):
    1.  
    2. function Start()
    3. {
    4.  
    5. StartServer();
    6.  
    7. }
    8.  
    9. function StartServer()
    10. {
    11.  
    12. MasterServer.ipAddress = "<My private IP";
    13. Network.InitializeServer(10,25005,!Network.HavePublicAddressI());
    14. MasterServer.RegisterHost("gameName","Game","comment");
    15.  
    16. }
    17.  
    18. function OnServerInitialized()
    19. {
    20.  
    21. //Enables a new script with a bunch of GUI
    22.  
    23. }
    24.  
    25.  
    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.

    Code (csharp):
    1.  
    2. function Awake()
    3. {
    4.  
    5. MasterServer.ipAddress = "<The IP of the Host Machine>";
    6. MasterServer.RequestHostList("gameName");
    7.  
    8. }
    9.  
    10. function OnGUI()
    11. {
    12.  
    13. var host: HostData[] = MasterServer.PollHostList();
    14.  
    15. for (var join in host)
    16. {
    17. GUI.Label(Rect(10,10,1000,25),"Server: ",+join.gameName+" is ready");
    18. if(GUI.Button(Rect(10,40,75,25),"Connect"))
    19. {
    20. Network.Connect(join);
    21. }
    22. }
    23.  
    24. }
    25.  
    26. function OnConnectedToServer()
    27. {
    28.  
    29. //Enables another scrip to display some GUI
    30.  
    31. }
    32.  
    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.

    Code (csharp):
    1.  
    2. function Awake()
    3. {
    4.  
    5. Network.natFacilitatorIP = "<The PUBLIC IP address to my modem>";
    6. Network.natFacilitatorPort = <The default 50005 when starting the Facilitator.exe>";
    7. MasterServer.ipAddress....
    8. .....
    9.  
    10. }
    11.  
    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.
     
    Last edited: Jan 9, 2013
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
  3. tecra134

    tecra134

    Joined:
    Mar 19, 2011
    Posts:
    94
    Followed the links recommendations and I've already opened the ports needed as described in the link.

    Could this be a code problem? I have sneaking suspicions that the issue hear lies with the HOST code. Right now I'm setting the "MasterServer.ipAddress" on the HOST machine with it's private IP? Is this the correct way? So in order, I launch the MasterServer.exe, launch the Facilitator.exe, launch the game with the MasterServer.ipAddress set to the machines private IP.

    Do I need to set the HOST machines IP to it's public IP or is fine using the private IP? (I'm trying to connect from outside my network)

    Do I need to put in the "Network.natFacilitatorIP" in the HOST code as well?

    And when I create the server, I notice the MasterServer.exe command prompt throw some text about the server rows and such....shouldn't the Facilitator.exe be doing something similar?

    Thanks!
     
  4. tecra134

    tecra134

    Joined:
    Mar 19, 2011
    Posts:
    94
    To be more specific I've opened all the necessary ports for the MasterServer.exe and Facilitator.exe. I've disabled the firewall on my machine as well as on my router. I've enabled DMZ seeing as that's my only option for NAT editing on my Router.

    I still can't help to think that my issue doesn't lay with the router/ports but with the code. I'm at the last phase of my project and that's getting it to run on its own server. And this is where I'm stuck.

    Does the above code seem correct to get a connection outside my local network as far as adding the "Network.natFacilitatorIP/Port" to the clients code?

    Help would be appreciated. :)