Search Unity

Receiving NAT punchthrough attempt from target ############## failed

Discussion in 'Multiplayer' started by dominik678, Jan 14, 2015.

  1. dominik678

    dominik678

    Joined:
    Jan 14, 2015
    Posts:
    6
    Hi!

    I've got a problem with my multiplayer game. I use my own Unity masterserver and facilitator at the moment and they are running on a server in my network.

    The connection to the masterserver works just fine. From 3G/EDGE/4G and WLAN there is no problem. If i open a game on my android phone i can see it from my other android phone. (the ports for masterserver and facilitator are open and forwarded)

    It is also possible to connect to a game while both devices are in the same network. But if i try to connect from a mobile network, an error occurs that says "Receiving NAT punchthrough attempt from target ############## failed".

    There are many threads like this in the forum but non of them seems to have a solution. I would be very grateful for a solution.

    Greetins Dominik
     
  2. dominik678

    dominik678

    Joined:
    Jan 14, 2015
    Posts:
    6
    if anyone has the same problem in the future.. give it up. It's not possible this way because of restrictions from the provider and in general it's not very clever. (not every router has the right ports forwarded)

    Just stick with this idea: build a dedicated server. This way you still need to open ports for the server and have a public IP or dyndns but there are no problems with the connection from mobile Networks like 3G/EDGE/4G or another LAN / WLAN. (Although it's not wise to allow mobile networks for a game unless it's turn based). And you won't get that nasty Nat problem i've described in my first post.

    Also what i figured out ist that the Masterserver saves the local IP of the Host into its HostData structure. (for an example if my public IP is 109.206.240.6 and my local IP is 192.168.3.33 it will store the last one). My workaround was to store the public IP into the comments of the HostData structure. (if your HostData object is called element you can just use element.comment to read out the comments)If you need to know how you can get your external IP just google it. There are plenty threads on this and a few solutions.

    If someone ever will need help with the dedicated server or wants to see my code feel free to contact me.

    Greetings Dominik
     
  3. rob_vld

    rob_vld

    Joined:
    Jul 9, 2013
    Posts:
    191
    So, i do not think this applies to you, your question looks more advanced, never tried mobile myself!... but this is what i just wrote in another post... perhaps it helps confirming things...

    With NAT you would need 3 ports available
    xxxx1 : Your router needs to point to your LAN-IP and forward to port xxxx1 (unsure about TCP or UDP so i set them both)
    xxxx2 : Your MasterServer port
    xxxx3 : Your NAT port

    ServerSide:
    MasterServer.ipAddress = 127.0.0.1;
    MasterServer.port = xxxx2;
    Network.natFacilitatorIP = 127.0.0.1;
    Network.natFacilitatorPort = xxxx3;

    Network.InitializeServer( 32, 127.0.0.1, true );
    32 = maximum simultaneous connects
    127.0.0.1 = your local host
    true for NAT

    ClientSide:
    Network.Connect( masterServerIP, xxxx1 );
    The masterServerIP must be your server WAN-IP and the port has to be your server forwarding port

    Also:
    If you are using a Unity based standalone server, make sure it is build to run on the background
    Make sure the application is allowed by your firewall.
     
  4. MadMenyo

    MadMenyo

    Joined:
    May 15, 2013
    Posts:
    23
    I have just been working 2 days straight on setting up a EC2 server. Just now ran into this error "Receiving NAT punchthrough attempt from target XXXXXXXXX failed".

    I want to use this for android vs android device. So port forwarding should not be an issue since anyone should be able to connect to my server.

    Has all my work been in vain? Or is there a solution for this?
     
    wyznawca likes this.
  5. wyznawca

    wyznawca

    Joined:
    Dec 27, 2012
    Posts:
    27
    Same here. IS there any solution?
     
  6. Bartagnan

    Bartagnan

    Joined:
    Nov 7, 2015
    Posts:
    2
    Hi All,

    Several months later, did you solve this issue?
    Working with version 4.6 where the masterserver & facilitator are hosted on an external provider (OVH), 3G is failing where connection though wifi is ok.
    An idea?
    Your help will be appreciated!
    Thanks.
     
  7. djoshi

    djoshi

    Joined:
    Mar 28, 2014
    Posts:
    182
    We have faced this error all the time "Receiving NAT punchthrough attempt from target XXXXXXXXX failed". And the horrible part is when you are testing (probably you are on same wifi) you connect 95%(So you are virtually happy, yeah I have my network working for free:D)but you release game & see lots of connection happening worldwide using different internet connections you end up with this error 95% :(:confused: And there is no workable solution to this error:eek:. So decided to look for other networking solutions :rolleyes:but all seems expansive (Have to keep paying monthly etc.):oops: except Google RTM :)but big issue how to quickly integrate in Unity:mad:, so decided to work on it & came out with easy to use plugin for all- Plus Networking - Have a look at it!
    For more info : http://forum.unity3d.com/threads/in...ng-solution-to-google-rtm-for-unity3d.365375/
    Asset Store : http://u3d.as/k9h
     
  8. Stargamer_285

    Stargamer_285

    Joined:
    Mar 13, 2016
    Posts:
    1
    Hi guys! I had the same problem but when I connected my devices to the same internet, (and turned data off) the error went away. Hope this helps!
     
  9. pbiesek92

    pbiesek92

    Joined:
    Feb 9, 2016
    Posts:
    11
    I found this problem only occur when i try to connect phone on 4G to a server hosted on my PC. when i tried the other way around (hosting on 4G and connecting with client on PC) it worked fine. so as long as you want to make a mobile game where one player would host a room and others can join, your networking solution should be good to go. only if you are trying to host a server on a PC for mobile clients, you gonna get this problem.