• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by jan09 · Feb 23, 2015 at 01:54 PM · serverclientinternet

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!;)

Comment
Add comment · Show 6
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image skylem · Feb 23, 2015 at 02:27 PM 1
Share

have you port forwarded your router to allow for incoming 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.

avatar image jan09 · Feb 23, 2015 at 03:01 PM 0
Share

Thank you:D

Sorry but i am very new to this: how do i know which ports to use for port forward??

avatar image skylem · Feb 23, 2015 at 03:18 PM 0
Share

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

avatar image jan09 · Feb 23, 2015 at 03:32 PM 0
Share

Thank you again sorry for my dumb question:p

avatar image jan09 · Feb 23, 2015 at 03:55 PM 0
Share

So i use the following code:

 Network.natFacilitatorIP = Network.player.externalIP;
 Network.natFacilitatorPort = Network.player.externalPort;
 Network.incomingPassword = "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  

Show more comments

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

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

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

21 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

RPC Error function not found 2 Answers

Client cannot connect to my local server over internet 0 Answers

Server hosting game 1 Answer

iOS using the client as the server 0 Answers

Help with multiplayer connection 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges