Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Master Server and NAT

Discussion in 'Connected Games' started by f22raptor, Nov 20, 2009.

  1. f22raptor

    f22raptor

    Joined:
    May 11, 2009
    Posts:
    5
    Hi. My apologies if this topic/issue has already be addressed.

    Using Unity 2.6 on a Mac running OSX 10.5.8.

    I have a server on a private network (with NAT punch through enabled) that successfully registers with Unity's master server (masterserver.unity3d.com) using port 23457. To test, I use a client sitting on the same private network and it is able to poll the master server and does get a valid list. However, the IP address and Port number contained in the received HostData is the private IP and the port that the server is listening on. Any attempts to connect using this results in a NATTargetNotConnected and the facilitator complains that the server @ private IP / port is not connected to it (the facilitator).

    While I understand why the attempt to connect to the server from the client is failing, what I do not understand is why is the IP address and port contained in the received HostData not the NAT'd info but rather is the server info sitting behind my router/gateway?

    I initialize the server, then invoke the registration. Debug shows everything working as expected:

    Server initializes successfully
    +- Connects successfully to Master Server
    +- Sends game/host registration info successfully
    +- Connects successfully to facilitator

    Am I doing something wrong? Thanks in advance for any help/insight to fix the issue.
     
  2. jackshiels

    jackshiels

    Joined:
    Feb 29, 2008
    Posts:
    357
    I'm sorry to bring back an old topic but I really need an answer to this also. I was browsing and saw that raptor is getting the exact same problem as me.

    Does anyone have knowledge of how to fix this issue?

    Thanks
     
  3. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    If both computers are on the same private network, then I am pretty sure it will not be using NAT punchthrough.

    To be sure check what the value of:
    hostData.useNat is for the server. And be sure to actually use that value when connecting.

    It should be clever enough to detect you are on the same network, then just tells you to connect to each other.
     
  4. Aubrey-Falconer

    Aubrey-Falconer

    Joined:
    Feb 13, 2008
    Posts:
    436
    It is clever enough to detect this, but it is also flawed enough to fail to do so most of the time...

    When hosting a game server on my computer then polling the master server through another game instance, I get a NAT reference 90% or so of the time. Occasionally, the Master Server will correctly provide me with the local reference.
     
  5. jackshiels

    jackshiels

    Joined:
    Feb 29, 2008
    Posts:
    357
    In my issue the game can connect via LAN easily, but any external connections are rejected :( I get that error.
     
  6. f22raptor

    f22raptor

    Joined:
    May 11, 2009
    Posts:
    5
    I got around the issue by checking the address returned by the Master Server when polled. If the address of the server belonged to a private network, I set Network.useNat to false before attempting to connect. So far, this work around has had no issues. Hope this helps anyone who might be interested in this issue. Thanks.
     
  7. CoherentInk

    CoherentInk

    Joined:
    Jul 16, 2006
    Posts:
    216
    I've definitely been having this problem too-- I can't wait to get home to try it out!

    Maybe we should add something to the wish list so that the useNat property is only applied to connections to non-private addresses? I imagine this is a relatively easy fix as part of connecting to players.
     
  8. ivanhoe

    ivanhoe

    Joined:
    Nov 18, 2009
    Posts:
    11
    i managed to sort my problem..

    a mix of bad setting on usingNat plus some .. bad luck i guess..

    plus maybe the facilitator was down, i wont be able to tell because of my own errors..

    thing is, now i have it all working fine..
     
unityunity