Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Receiving NAT punchthrough attempt from target xxxxxxxx failed

Discussion in 'Multiplayer' started by MrGamer, Dec 19, 2013.

  1. MrGamer

    MrGamer

    Joined:
    Jan 10, 2013
    Posts:
    22
    Hello everyone
    I am doing programming for multi player game. i host the master server on the dedicate server. when i play game from same server it work fine. When i connect my pc to local wifi network and use mobile with the mobile data then i receive this error.

    Receiving NAT punchthrough attempt from target 2076982475 failed

    here is my code
    Code (csharp):
    1.    
    2.          void launchServer(){
    3.         Network.InitializeSecurity();
    4.         Network.InitializeServer(32, 25300, !Network.HavePublicAddress());
    5.         MasterServer.RegisterHost(gameTypeName, gameName);
    6.     }
    Code (csharp):
    1.  
    2.          void joinServer(){
    3.         refreshHostList();
    4.  
    5.     }
    6.  
    7.     void refreshHostList(){
    8.          MasterServer.RequestHostList(gameTypeName);
    9.     }
    10.  
    11.     void OnMasterServerEvent(MasterServerEvent msEvent) {
    12.    
    13.         if (msEvent == MasterServerEvent.RegistrationSucceeded)
    14.             Debug.Log("Server registered");
    15.  
    16.         if(msEvent == MasterServerEvent.HostListReceived){
    17.             if(MasterServer.PollHostList().Length != 0){
    18.                 hostData = MasterServer.PollHostList();
    19.                 Network.Connect(hostData[0]);
    20.             }else
    21.                 refreshHostList();
    22.         }
    23.        
    24.     }

    i can see from the game log and master server log that server connect successful. It means game can connect successfully to the master server as the server. Problem occurs when client try to connect with the game server. Any solution or any idea of error. :sad:
    Thanks
     
  2. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    I've had this problem before too, on Android. I found it seemed to happen at the start of the day, then after a while it would fix itself - usually just when I started trying to debug it - and I wouldn't be able to reproduce the problem any more, until the next morning. As a result I didn't get far with diagnosing it.

    I noticed that the GUIDs on the Android devices in these cases seemed rather short numbers (like the one you pasted) compared to the usual longer ones, but I don't know whether that was the cause - I think I saw it successfully connect even with these odd GUIDs in some cases, so it's not terminal. I tried running my own NAT facilitator too, but it didn't make any difference - the problem seemed to happen anyway, and the facilitator doesn't print anything interesting in its logs.
     
  3. MrGamer

    MrGamer

    Joined:
    Jan 10, 2013
    Posts:
    22
    I am not using android to test it. This number is from unity and it print big number in xcode when testing on iphone. To test it i am using iphone running on mobile data. unity on local wifi and master server on dedicate machine.
    Any other idea
     
  4. MrGamer

    MrGamer

    Joined:
    Jan 10, 2013
    Posts:
    22
  5. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    Do you also get an error stating that the facilitator doesn't recognize the GUID? It was a few months ago but I think for me one of the devices would report this error, and the other would report the error you pasted in your first post. It is what made me think that there was some problem with the GUIDs that the mobile devices were generating.
     
  6. MrGamer

    MrGamer

    Joined:
    Jan 10, 2013
    Posts:
    22
    no i am getting same error on both devices but guid number change. there is no error from facilitator or proxy server. i can see from both server devices are connecting with them. i cant find where the error is
     
  7. Nesokas

    Nesokas

    Joined:
    Jun 30, 2013
    Posts:
    13
    Can anyone explain me why this error happens?
     
  8. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    I am getting this same error. It work fine if i connect to same network, But when i tried from different netowrks,it not, any help?? you found solution, any alternatives?
     
  9. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    Its probably your routers thats the problem. Look into Unity's Master Server
     
  10. Quaker_SDR

    Quaker_SDR

    Joined:
    Jun 21, 2013
    Posts:
    39
    What should i have to look for? Its not blocking any port. Syntax is right. Can you guide me in which part there will be problem?
     
    Last edited: Dec 30, 2014
  11. dominik678

    dominik678

    Joined:
    Jan 14, 2015
    Posts:
    6
    Were you able the solve the Problem? I'm stuck at the same thing.. thx :)
     
  12. wyznawca

    wyznawca

    Joined:
    Dec 27, 2012
    Posts:
    27
    Yep, i am waiting for solution too.