Before updating to Windows 10 you may need to return your Pro license. More information here

Details on working with a home-hosted master server ?

More precisely, I would like to know what must be modified in the ConnectGUIMasterServer.js script of Unity's networking example to have it work reliably with a home-hosted master server, whatever the players' locations (LAN or external).

Thanks in advance :-)

more ▼

asked Dec 16, 2009 at 03:30 PM

avatar image

61 4 4 11

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

A home hosted master server might be a little troublesome. One of the things the master-server helps you with is NAT punchthrough - which requires that the machine the master-server is running on has a direct connection to the Internet, which usually is not the case for "home-based server".

So, unless you've got an Internet provider that gives you a public IP for your specific server and unless you have that server directly connected (without any IP-forwarding or NAT), it'll be hard to get connections created through such a home-based master server to be reliable.

That said: You can use MasterServer.ipAddress and MasterServer.port to let Unity know the data of your local MasterServer. Just make sure this is done before you actually use the MasterServer (e.g. for connecting), so you'd probably put the relevant statements right in the beginning of ConnectGuiMasterServer.js; something like:

private var testMessage = "Undetermined NAT capabilities";

// Enable this if not running a client on the server machine //MasterServer.dedicatedServer = true;

// => this is added START

MasterServer.ipAddress = ""; // your public IP-address MasterServer.port = 12345; // the port your master-server uses (or leave that out if you use the default port)

// END until here ;-)

function OnFailedToConnectToMasterServer(info: NetworkConnectionError) { Debug.Log(info); }

more ▼

answered Dec 16, 2009 at 11:00 PM

avatar image

12.3k 51 152 230

So clear, concise and helpful ! I had missed the point about the master server needing to have a direct connexion to the internet, and thought that having a permanent public IP was enough. Thank you very much, Jashan, this is exactly the answer I needed :-)



Dec 17, 2009 at 12:44 AM Yann
(comments are locked)
10|3000 characters needed characters left

If you want to make it accessable to the outer world and would like to use one of the free static domain redirectors for that (no-ip.org / dyndns), then you need to expand the code slightly, as the ipAdress property of the master server etc only accepts the regular tupples. Also, you can not only set the master server adress and port but also the one of the connection tester and facilitator, which you will have to host along with the master server, should you require these functionalities. The connection tester will obviously handle the connection test, while the facilitator is used for the NATPunchthrough. Here is an example

string masterServerUrl = "master.yourdomain.no-ip.org"; System.Net.IPHostEntry ip = System.Net.Dns.GetHostEntry (masterServerUrl); System.Net.IPAddress[] ipA = ip.AddressList; if (ipA.Length > 0) { MasterServer.ipAddress = ipA[0].ToString(); MasterServer.port = 12345; }

masterServerUrl = "contester.yourdomain.no-ip.org"; ip = System.Net.Dns.GetHostEntry (masterServerUrl); ipA = ip.AddressList; if (ipA.Length > 0) { Network.connectionTesterIP = ipA[0].ToString(); Network.connectionTesterPort = 10735; }

masterServerUrl = "facilitator.yourdomain.no-ip.org"; ip = System.Net.Dns.GetHostEntry (masterServerUrl); ipA = ip.AddressList; if (ipA.Length > 0) { Network.natFacilitatorIP = ipA[0].ToString(); Network.natFacilitatorPort = 50000; }

more ▼

answered Dec 17, 2009 at 12:12 PM

avatar image

3.7k 4 11 41

Very useful, thank you Dreamora !

Dec 18, 2009 at 07:44 PM Yann
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Dec 16, 2009 at 03:30 PM

Seen: 4902 times

Last Updated: Dec 16, 2009 at 03:30 PM