I’m a bit beginner in Unity networking (and networking…).
I have a server and a client, i want to my client connect to the server through internet (no local adresses so.).
I initialize my server with Network.InitializeServer(), and put useNat to true because the function HavePublicAdress() return me “false”.
I connect my client with Network.Connect(), and put the externalIP and externalPort value of my server in parameters of this function.
My server starts okay, but for my client Unity said “The connection request failed”, and the TestConnection() function return me “LimitedNATPunchtroughPortRestricted”.
Did i miss something ? I think it’s because of my private ip adress, but how to connect in this case ?
You need to make it connect to a master server after initializing the server as you need NAT PunchThrough to connect from the outside, as this is handled and routed through the master server.
Without a master server you will have to force everyone who hosts games to setup UDP portforwards on his router and firewall.
A word of warning on this though: do better not rely on the inbuilt default addresses for masterserver, nat facilitator and connection tester as especially the nat facilitation on the UT servers are often not reachable and working. Also they are not for production use in any form so sooner or later you will be required to handle this yourself in some form.
The manual part of the documentation contains further information on the matter of the master server
“Without a master server you will have to force everyone who hosts games to setup UDP portforwards on his router and firewall”
…which still may not work because of your internet-provider NAT. So, even if you’re writing simple two-person chat software you still need an outer server.