- Home /
Server Client internet connection
Hello!
My situation: 1 PC in known WLan; 2 Android phones in different and unknown networks.
Both of the phones know the ip and the port (local and external!) of the first PC which host a server. How can i connect from the phones to the server. It only works for me if the phones are in the same network as the PC (--> with local ip and local port) but if i try this with different networks it does not work at all!
Edit: As far i used Network.Initialize(...) and Network.Connect(...) - with and without NAT
Any suggestion?
Thanks in advance!;)
have you port forwarded your router to allow for inco$$anonymous$$g connections? this is usually the case when your not able to receive connections outside your router? you may also need to change the NAT settings depending upon the Router you use for internet connection you do all this via your router website page usually 192.168.0.1 or 10.0.0.1 if its neither open Command prompt(start menu > search "cmd") type ipconfig and hit enter whatever ip you have as Default Gateway will take you to your router setup.
Thank you:D
Sorry but i am very new to this: how do i know which ports to use for port forward??
Thats totally your decision and example could be 4455 but really you can choose any combination of numbers, however if you are using windows you will also need to open these ports within windows http://windows.microsoft.com/en-au/windows/open-port-windows-firewall#1TC=windows-7
So i use the following code:
Network.natFacilitatorIP = Network.player.externalIP;
Network.natFacilitatorPort = Network.player.externalPort;
Network.inco$$anonymous$$gPassword = "password";
Network.InitializeServer (100, 5274, !Network.HavePublicAddress());
But for some reason this works only in the editor! In the editor it uses the public ip of my router and the correct port. In the build it uses an other port and the extarnal ip is: UNASSIGNED_SYSTE$$anonymous$$_ADDRESS
EDIT: If i delete this:
Network.natFacilitatorIP = Network.player.externalIP;
Network.natFacilitatorPort = Network.player.externalPort;
i got the correct external ip in the build but a incorrect external port. In addtion i got an error message in the editor:
NAT target 0 not connected to NAT faciliator ip:port
Your answer
![](https://koobas.hobune.stream/wayback/20220613184120im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
RPC Error function not found 2 Answers
Client cannot connect to my local server over internet 0 Answers
Networking Question 1 Answer