Search Unity

NAT Traversal - Automatic port forwarding, punch-through, and more!

Discussion in 'Assets and Asset Store' started by thegreatzebadiah, Apr 5, 2016.

  1. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Sorobaid I just confirmed, much to my disbelief, that the version of the Facilitator that I've been packaging with the plugin forever now is wrong and old. Really not sure how that happened. I'll make sure to fix it in the next release but in the meantime you should try one of these links:
    @RayKatz You may also want to give those a try, maybe I already got it working for 32bit linux and I've just been packaging the wrong one with the plugin, it's been so long I honestly cant remember.
     
  2. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    226
    I forget what I did, it was something with the client not shutting down properly. It's fine now though. Thanks.
     
  3. Sorobaid

    Sorobaid

    Joined:
    Aug 31, 2012
    Posts:
    13
    @thegreatzebadiah Yes, this one actually works. I use the -i option to choose the ip and I can finally connect to the facilitator. Thanks.
    By the way out of topic, can I change the relay to use not Unity Relay, but open source turn server like coturn?
     
  4. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Awesome.

    I imagine this is theoretically possible but I'm not sure how you would go about it. I didn't even know something like coturn existed or I probably would have looked into this sooner. I'm going to consider implementing a built in way to connect to a coturn server but no promises yet. In the mean time if you make any progress on your own I'm sure others would appreciate if you post back here with anything you figure out.

    I've been putting off self-hosted relay support for so long because it seemed super hard but now that I look into it a bit it's maybe not so bad?...I guess I'll find out. Thanks for pointing me to coturn.
     
  5. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    I installed the latest version of Nat traversal, match up and the match up server Windows. I am using unity 2017.3. When I connect to the matchmaker I get this error:
    upload_2018-3-21_12-53-33.png
    I get the error when I connect with my own code or the example match up. It seems to be trying to parse the GUID as an int.
     
  6. Deleted User

    Deleted User

    Guest

    Thank you for having this asset in the asset store, i have buy it but right now i cant test it, it looks like the Facilitator "grabblesgame.com" on port "61111" is down.

    I just played the Example scene but i cant have a connection to the Test-Facilitator.
     
  7. koniouchine

    koniouchine

    Joined:
    Mar 3, 2018
    Posts:
    5
    Same issue, not sure if I missed something. But it is the example scene.

    EDIT:
    I am however able to connect to my AWS EC2 server as per the FAQ instructions.
    For others, just make sure it's the 14.04 Ubuntu. Not 16.*** Ubuntu
    I couldn't get it to work on the 16*** ubuntu for Amazon.
     
    Last edited: Mar 23, 2018
  8. Sorobaid

    Sorobaid

    Joined:
    Aug 31, 2012
    Posts:
    13
    @thegreatzebadiah
    Sure, I also need help just in case if I want to connect it to unet which I am still not getting into yet. But right now I am being pointed to using WebRTC. There is an asset in the store that is free, so far I try to use my turn server and now I can connect to my other PC on mobile phone data. Since it is also used mainly for web browser connection so it might be able to be used for WebGL/ android. Interested with this? *wink
     
  9. TheFoundation

    TheFoundation

    Joined:
    Jan 29, 2014
    Posts:
    20
    I just purchased NAT Traversal and Match Up. The "NAT Traversal Example/Extras/Match up" example throws exceptions.

    Reproduction:
    Setup: Import the NAT Traversal and the Match Up asset. Setup the Unity Service Multiplayer for the project and define MATCH_UP as a scripting define symbol.
    Play: Open the NAT Traversal Example/Extras/Match up" scene and hit "Play" in the Unity Editor.

    Disconnect exception:
    1. Click "Host"
    2. Click "Disconnect".
    3. Result: Matchmaker.DestroyMatch() is called where Matchmaker.currentMatch is used but it is null. This results in:
    NullReferenceException: A null value was found where an object instance was required.
    MatchUp.Matchmaker.DestroyMatch (System.Action`1 onDestroyMatch) (at Assets/Plugins/Match Up/Matchmaker.cs:266)
    ExampleMatchUp.OnGUI () (at Assets/NAT Traversal Example/Extras/Match Up/ExampleM
    atchUp.cs:59)​

    Match exception:
    1. Click "Search Matches"
    2. Result: Access of matches.matchData["Match Name"] in ExampleMatchUp.OnGUI() results in exception:

    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,MatchUp.MatchData].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    ExampleMatchUp.OnGUI () (at Assets/NAT Traversal Example/Extras/Match Up/ExampleMatchUp.cs:77)

    Note:
    The "Match Up Example" and the "NAT Traversal Example" seem to be working tough.

    Environment:
    * Windows 10 64 bit
    * Unity 201.04.0f1 (latest)
    * NAT Traversal ver. 1.58 (latest)
    * Match Up ver 1.04 (latest)

    Can anyone confirm this?

    To be honest, I am surprised that an asset with such a good reputation ships broken examples. I am wondering if it is actually broken and how I could have caused these issues. Thanks.
     
  10. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    I think he tried to simplified some things in the latest version but broke some things in the process or doesn't have error checking. I get the same errors for both.The second one uses a new way of getting results that doesn't work. I use the more complicated old method.

    Code (CSharp):
    1.  if (matches != null && !showDisconnectButton)
    2.         {
    3.             for (int i = 0; i < matches.Length; i++)
    4.             {
    5.                 string newString = "";
    6.                 foreach (KeyValuePair<string, MatchData> kvp in matches[i].matchData)
    7.                 {
    8.                     if (kvp.Key != "port" && kvp.Key != "internalIP" && kvp.Key != "applicationID" &&
    9.                         kvp.Key != "externalIP")
    10.                     {
    11.                         newString += " | " + kvp.Value;
    12.                     }
    13.                 }
    14.                 if (GUI.Button(new Rect(170, 10 + i * 26, 600, 25), newString))
    15.                 {
    16.                     showDisconnectButton = true;
    17.                     this.JoinMatch(matches[i], OnJoinMatch);
    18.                  
    19.                 }
    20.             }
    21.         }
     
  11. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    Still having this issue:
    installed the latest version of Nat traversal, match up and the match up server Windows. I am using unity 2017.3. When I connect to the matchmaker I get this error:

    I get the error when I connect with my own code or the example match up. It seems to be trying to parse the GUID as an int.
     
  12. Deleted User

    Deleted User

    Guest

    Looks more like a ulong, a int cant hold this value, but i think this don't helps you really well, a GUID have not only numerical values in it and this is the reason you cant Pars a GUID to a Numerical value, maybe this helps.
     
  13. Kobaltic1

    Kobaltic1

    Joined:
    Jan 22, 2015
    Posts:
    183
    Thanks, I get that. I just don't understand. There is a parser for the ulong but it is using the int parser and I don't know why and it is this way straight from the store. I didn't change anything.
     
  14. othercrow

    othercrow

    Joined:
    Oct 19, 2013
    Posts:
    16
    Hi, I have the Facilitator running an AWS ec2 instance (linux), but the Facilitator does not seem to recognize my public ipv4 address, instead only picking up both private ipv4 addresses.
    This is occurs with both the asset store version and the version you linked recently on your site, even with all ports/traffic open and unrestricted on AWS.
    Attempting to force the correct ip address ./Facilitator -i does not work.
    facilitator problem.JPG

    UPDATE: This is probably an AWS specific issue and not Nat Traversal's fault. Displays private ip addresses on an Azure Ubuntu vm also, but actually works properly there.
     
    Last edited: Apr 5, 2018
  15. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
  16. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Kobaltic1 @TheFoundation These errors are all actually from improved error handling I added that went a bit overboard...

    Not my finest moment.

    Sorry for the issues, I know how frustrating it is when things don't work right out of the box. Usually we're pretty good about that, which is why we include so many examples, but lots of examples means lots of things that can go wrong when things change.

    Contact me via email and I can get you an updated build that actually works :)
     
    Last edited: Apr 5, 2018
  17. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Hmm, usually that works in cases like this. What specific operating system is your ec2 version using so I can spin one up and test.
     
  18. othercrow

    othercrow

    Joined:
    Oct 19, 2013
    Posts:
    16
    The ec2 was running a t2.micro running this ami (probably the first on free-tier the list):
    Code (CSharp):
    1. Amazon Linux AMI 2017.09.1 (HVM), SSD Volume Type - ami-1853ac65
    For comparison, my Ubuntu VM on Azure also does not list the public ipv4, but can still be connected to properly:
    facilitator on azure.JPG
     
  19. TheFoundation

    TheFoundation

    Joined:
    Jan 29, 2014
    Posts:
    20
    No worries. I was just wondering if anyone can confirm these issues.

    Thanks for looking into it.
    I contacted you 13 days ago (using the address you published on noblewhale.com) but did not receive any reply. What's the correct address?
     
    Last edited: Apr 5, 2018
  20. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    You got it right I just missed your email. I found it though and sent you the latest build.
     
  21. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I don't want to over promise anything at the moment but I may have something coming for this. I've been experimenting with CoTurn and so far results look promising. That's all I'll say for now so I don't end up eating my words :)
     
    adhi_c_l likes this.
  22. TheFoundation

    TheFoundation

    Joined:
    Jan 29, 2014
    Posts:
    20
    Superb, thanks!
     
  23. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    othercrow likes this.
  24. othercrow

    othercrow

    Joined:
    Oct 19, 2013
    Posts:
    16
  25. Game-Armada

    Game-Armada

    Joined:
    Apr 29, 2013
    Posts:
    66
    Is this package still only works for desktop computers? (no device)
     
  26. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
  27. Minamu

    Minamu

    Joined:
    Apr 28, 2014
    Posts:
    5
    I'm considering getting all three of your products, just need to consult with my team first. Correct me if I'm wrong, this Facilitator is an app I should run on a dedicated web host and/or a separate server at home? Can it be used by the players themselves to set up their own servers? As I interpret it, the Facilitator helps with organizing a list of lobbies/servers for players to connect to, visible in-game somehow, but can I skip that part if I'd like and only allow direct P2P connections with your assets (I don't mind turning off relay servers, even if it means the connection rate isn't 100%)? Basically, our budget is less than 0 ;)
     
  28. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yep

    In theory yes, but they would have to do manual port forwarding or not be behind a router so it kind of defeats the purpose of the Facilitator. A Facilitator server is very cheap to run though. I believe Amazon even has some free servers that are suitable. The amount of bandwidth used is very minimal, just a couple bytes for each each game that is hosted and player that joins.

    You're also free to use our Facilitator at grabblesgame.com during development and testing, we just don't guarantee any kind of up time.
     
  29. Minamu

    Minamu

    Joined:
    Apr 28, 2014
    Posts:
    5
    Thanks for the quick response! So if I understand all of it correctly, if I combine your Match Up with NAT Traversal (and possibly the Facilitator), I can circumvent Unity's costs entirely, if I don't bother with the relays? Can I do both lobby lists and direct connections that don't show up in a list (I think that's what the Facilitator is primarily for)?

    Either way, I'm surprised Unity allows these assets on their store lol.
     
  30. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yep :)

    Yeah, you can do both. The Facilitator is used regardless of if a match is selected from a lobby list or some other way. The only difference is that if you're not getting it from Match Up / Unity Matchmaking then you've got to pass the connection info around some other way (steam friend joining? passing some code via instant message? etc). The Facilitator does not provide any way to get a list of hosts on it's own.
     
  31. Minamu

    Minamu

    Joined:
    Apr 28, 2014
    Posts:
    5
    Sounds great, you got me sold on it at least :) I'll have a chat with my team about it, but it sounds like a done deal to me hehe. Seems wasteful to code our own server solution as has been discussed internally, when this stuff is available.
     
    thegreatzebadiah likes this.
  32. Viggy1996

    Viggy1996

    Joined:
    May 11, 2017
    Posts:
    39
    @thegreatzebadiah Can I use this for my Android/ IOS Project? From the FAQs from the Asset Store, It seems it not implemented yet. Is it possible to achieve NAT Punch-through in Mobiles?
     
  33. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @LemurusBalok It is theoretically possible to do punchthrough in android/ios over wifi. It is not possible over satellite networks.

    Unfortunately NAT Traversal doesn't support mobile at all so you can't even use it for wifi. This may finally change in the next few months if my latest project works out how I expect because I will be able to switch away from RakNet to some more cross-platform friendly code. I really can't promise anything at the moment though because I'm not 100% sure things are going to work out the way I expect.

    Sorry to be vague, the short answer is: No mobile support, but it still might be coming.
     
  34. Gotcab

    Gotcab

    Joined:
    Apr 22, 2017
    Posts:
    6
    Hi, I encouter a recuring prolem when importing NAT Traversal. As soon as it finished importing, Unity throw a System.InvalidOperationException : Operation is not valid due to the current state of the object.

    Here is the full error :

    System.InvalidOperationException: Operation is not valid due to the current state of the object.
    at Mono.Cecil.ModuleDefinition.ReadSymbols (Mono.Cecil.Cil.ISymbolReader reader) [0x0002f] in <a3989f8c34e6476eaca56644d5639ee8>:0
    at Mono.Cecil.ModuleReader.ReadSymbols (Mono.Cecil.ModuleDefinition module, Mono.Cecil.ReaderParameters parameters) [0x0004a] in <a3989f8c34e6476eaca56644d5639ee8>:0
    at Mono.Cecil.ModuleReader.CreateModule (Mono.Cecil.PE.Image image, Mono.Cecil.ReaderParameters parameters) [0x00081] in <a3989f8c34e6476eaca56644d5639ee8>:0
    at Mono.Cecil.ModuleDefinition.ReadModule (Mono.Disposable`1[T] stream, System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0000d] in <a3989f8c34e6476eaca56644d5639ee8>:0
    at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x0006c] in <a3989f8c34e6476eaca56644d5639ee8>:0
    at Mono.Cecil.AssemblyDefinition.ReadAssembly (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <a3989f8c34e6476eaca56644d5639ee8>:0
    at AssemblyUpdater.Core.AssemblyUpdaterContext.ReadAssembly (System.String assemblyPath, APIUpdater.Framework.Log.IAPIUpdaterListener listener, System.IO.FileAccess mode, System.String[] searchPaths) [0x00071] in <3f368bacb6c34f4db5fe7e90570f303a>:0
    at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, APIUpdater.Framework.Configuration.IConfigurationProvider configuration, System.String[] assemblySearchPaths, AssemblyUpdater.Core.UpdaterMode mode, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x0002b] in <3f368bacb6c34f4db5fe7e90570f303a>:0
    at AssemblyUpdater.Core.AssemblyUpdaterContext.From (System.String assemblyPath, System.String[] assemblySearchPaths, AssemblyUpdater.Core.UpdaterMode mode, APIUpdater.Framework.Log.IAPIUpdaterListener listener) [0x00001] in <3f368bacb6c34f4db5fe7e90570f303a>:0
    at AssemblyUpdater.Application.Program.CheckForObsoleteAPIUsage (AssemblyUpdater.Application.CommandLineSpec config) [0x00013] in <3f368bacb6c34f4db5fe7e90570f303a>:0
    at AssemblyUpdater.Application.Program.Main (System.String[] args) [0x00057] in <3f368bacb6c34f4db5fe7e90570f303a>:0
    UnityEditor.Scripting.APIUpdaterHelper:DoesAssemblyRequireUpgrade(String)

    I tried looking for it but don't know where this come from.
    Here is a link I found to a similar error, maybe it will help :
    https://answers.unity.com/questions/852155/invalidoperationexception-operation-is-not-valid-d-1.html

    I'm on Windows 10, this happend on 2017.4.1f1 in a new project
     
  35. Gotcab

    Gotcab

    Joined:
    Apr 22, 2017
    Posts:
    6
    Hi, I'm havin a problem with NAT Traversal with the ExampleMatchUp scene. On my pc it works well but on my laptop I always have NATHelper: Something when wrong mapping port 7777 or 0 for both TCP and UDP. Then my client disconnect because of TimeOut. Both computers are on windows 10 connected to the same router. My laptop uses a Killer network card... maybe its a problem. When my laptop tries to connect to pc, on my PC I get the message Hole is punched on port: ****** but it does not connect. I could send you the project but it's a new project with only NAT Traversal and Match up on 2017.4.1f1. I'm on Standalone Windows x64 build.
     
  36. jaglitegrann

    jaglitegrann

    Joined:
    Feb 25, 2014
    Posts:
    10
    Hi, I am having some trouble using this plugin.

    I want to use automatic port forwarding and punch-through with unity's relays as a backup. But I can't get it to work with unity's relays. I unticked "Connect Directly" and "Connect Punchthrough" temporarly in the networkmanager to be able to see unity relays work in action. The host seems to start fine but clients can't connect, they trying for a while then getting an "ClientDisconnected due to error: Timeout" error.

    I am using this plugin together with steam matchmaking and I feel unsure about how the implementation of the plugin should be done.

    Here are an example of how I am using the plugin, I have removed all code not related to the plugin.

    Code (CSharp):
    1. public class MatchmakerExample {
    2.  
    3.     public static SteamLobby m_lobby;
    4.     public static uint m_matchPlayerCount;
    5.  
    6.     //called by lobby owner (the host) to start hosting a game.
    7.     static void HostGame() {
    8.         NATTraversal.NetworkManager netMgr = NetworkManager.singleton as NATTraversal.NetworkManager;
    9.         netMgr.StartHostAll("RandomName", m_matchPlayerCount, true, "", 0, 0, 0, matchInfoCallback);      
    10.     }
    11.  
    12.     //Callback from netMgr.StartHostAll
    13.     private static void matchInfoCallback(bool success, string extendedInfo, MatchInfo matchInfo) {
    14.         NATTraversal.NetworkManager netMgr = NetworkManager.singleton as NATTraversal.NetworkManager;
    15.  
    16.         //create a network message containing information on how to connect to the host
    17.         NetworkWriter networkWriter = new NetworkWriter();
    18.         networkWriter.Write((int)MsgType.StartMatch);               //Message type
    19.         networkWriter.Write(netMgr.externalIP);                     //external ip
    20.         networkWriter.Write(Network.player.ipAddress);              //internal ip
    21.         networkWriter.Write(netMgr.networkPort);                    //port
    22.         networkWriter.Write(netMgr.natHelper.guid);                 //guid
    23.         networkWriter.Write((ulong)matchInfo.networkId);  //matchID
    24.  
    25.         //Save connection information in the lobby as it may be useful for late joins and what not.
    26.         SteamMatchmaking.SetLobbyData(m_lobby.m_lobbyID, "externalIP", netMgr.externalIP);
    27.         SteamMatchmaking.SetLobbyData(m_lobby.m_lobbyID, "internalIP", Network.player.ipAddress);
    28.         SteamMatchmaking.SetLobbyData(m_lobby.m_lobbyID, "port", netMgr.networkPort.ToString());
    29.         SteamMatchmaking.SetLobbyData(m_lobby.m_lobbyID, "guid", netMgr.natHelper.guid.ToString());
    30.         SteamMatchmaking.SetLobbyData(m_lobby.m_lobbyID, "matchID", matchInfo.networkId.ToString());
    31.  
    32.         //Send connection information as a chat message that clients reads and connects to.
    33.         SteamMatchmaking.SendLobbyChatMsg(m_lobby.m_lobbyID, networkWriter.AsArray(), networkWriter.AsArray().Length);
    34.     }
    35.  
    36.     //event triggered when getting a new steam chat message.
    37.     static void onLobbyChatMsg(LobbyChatMsg_t result) {
    38.         //get the content of the chat message
    39.         CSteamID userId;
    40.         byte[] data = new byte[4000];
    41.         EChatEntryType chatEntryType;
    42.         int writtenBytes = SteamMatchmaking.GetLobbyChatEntry((CSteamID)result.m_ulSteamIDLobby, (int)result.m_iChatID, out userId, data, 4000, out chatEntryType);
    43.         System.Array.Resize(ref data, writtenBytes);
    44.         NetworkReader networkReader = new NetworkReader(new NetworkWriter(data));
    45.         MsgType msgType = (MsgType)networkReader.ReadInt32();
    46.  
    47.         //if is lobby owner (the host)
    48.         if (SteamMatchmaking.GetLobbyOwner(m_lobby.m_lobbyID) == SteamUser.GetSteamID()) {
    49.             //..........
    50.         } else { //if not lobby owner (not the host)
    51.            //message type is "StartMatch" wich is a signal for our clients to join the hosts game.
    52.            if (msgType == MsgType.StartMatch) {
    53.                 string externalIP = networkReader.ReadString();
    54.                 string internalIP = networkReader.ReadString();
    55.                 int port = networkReader.ReadInt32();
    56.                 ulong guid = networkReader.ReadUInt64();
    57.                 ulong matchIDValue = networkReader.ReadUInt64();
    58.  
    59.                 NATTraversal.NetworkManager netMgr = NetworkManager.singleton as NATTraversal.NetworkManager;
    60.                 UnityEngine.Networking.Types.NetworkID matchID = (UnityEngine.Networking.Types.NetworkID)matchIDValue;
    61.                 netMgr.StartClientAll(externalIP, internalIP, 0, guid, matchID);
    62.             }
    63.         }
    64.     }
    65.  
    66. }
    inspectorNat.png


    I tried using unity's matchmaking without this plugins and it worked well so I don't think that their is anything wrong setup in the unity multiplayer service.

    I am using Unity version 2017.3.1f1

    Is there something I done wrong or missing, I am out of clues sadly.
    Hopefully someone could point me in the right direction :)
     
    Last edited: Apr 23, 2018
  37. Mr-Cattz

    Mr-Cattz

    Joined:
    Feb 24, 2015
    Posts:
    3
    I think it might be a good idea to add that in to your short tutorial vid, this took me quite a long time to find! but I'm glad it was nothing major.
     
  38. jtesler

    jtesler

    Joined:
    Jul 19, 2017
    Posts:
    6
    We are developing an internal product, and don't want our traffic routed through external (Unity's) servers. We also need to deal with various company firewalls. I saw NAT Traversal and Match Up, and was wondering if they would work. I know you say that NAT Traversal is not 100% reliable, but since you have a Demo available on the NAT Traversal Asset page, I downloaded that and tried it. Using the demo, I was able to reliably connect between three different company intranets, as well as the AT&T network using my phone as a wi-fi relay. So I purchased the products, and tried building the Match Up ExampleMatchUp demo. This works on a local network between two machines on the same network, but cannot connect to a remote network. When I try to connect, I get the "NATHelper: Unexpected raknet message received: ID_NAT_PUNCHTHROUGH_FAILED" message. I'm wondering if the downloadable demo falls back to Unity, in which case I wasn't even testing the NAT code. (I tried turning on "Connect Relay" in my code and it didn't help, but it is possible we don't have the Unity relay set up right in this project; since I am not interested in Unity relay anyway, I haven't pursued this.) Would you expect this code to work between corporate firewalls?

    Some additional information: For testing, I am just using the grablegames facilitators and matchup servers. I have set the MATCH_UP environment variable, and the match is seen. So I think that MatchUp is working.

    Thanks for your help.
     
  39. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @jtesler The demo does indeed fall back to relays when NAT Traversal is not possible. Honestly I didn't even believe that was the case until I just went and double checked. I guess my reasoning was that a proper demo would also demo falling back, but in retrospect that's kind of silly. The whole point of the demo is to test if the NAT Traversal works. I'll get an updated one up right away so I'm not giving people a false impression.

    As for your actual issues, I'm afraid punchthrough just isn't going to work in your case. That's almost always what ID_NAT_PUNCHTHROUGH_FAILED means. Unfortunately that means you're either going to need relays or you're going to need to reconfigure your company intranets to allow nat. Sorry if the demo gave you the wrong impression, hopefully you'll still find the assets useful since you want to avoid Unity's stuff, but if you'd like to request a refund hit me up at the support email with your invoice number.

    Maybe some good news though, I'm working on a new asset right now that will allow you to host your own relays (or have us host and manage them instead of Unity). It's not ready for public consumption quite yet but it's coming together nicely. If you need to be able to connect right away I'd go with Unity's relays. If you can wait a month (or maybe a few) I might have something for you.
     
    Last edited: Apr 28, 2018
  40. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    This is almost always due to a firewall somewhere in the path, either on the server, the client, or the router.
     
  41. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I've never been able to get this to go away but it seems to be harmless.
     
  42. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I'm fairly sure the problem is that you're not passing in the server's port to StartClientAll().
     
  43. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Update: I just added a section to the FAQ explaining how to start the Facilitator automatically when your server boots, and how to restart it automatically if it crashes. Thanks @jiak1 for helping me figure it all out.
     
  44. Gotcab

    Gotcab

    Joined:
    Apr 22, 2017
    Posts:
    6
    Hi Zebadia,
    You gave us new versions of Facilitators for windows and linux at the top of this page and I would like to know if these are the ones included in the current version of NAT Traversal.
     
  45. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Gotcab I believe some people have been having issues with the Facilitator that is packaged in the plugin, so if it gives you problems go with the one linked here. They are definitely not the same. I'm not sure when the mixup happened but I'll have the correct Facilitator packaged in the next update.
     
  46. jaglitegrann

    jaglitegrann

    Joined:
    Feb 25, 2014
    Posts:
    10
    Thank you for your answer :)
    I tried to pass in the port to "StartClientAll()" as you suggested, but it gave the same result. Is it the "networkPort" member variable on the networkmanager from the host that should be passed in?

    Do I need to do anything in the "JoinMatchCallback" of "StartClientAll()"? I have assumed everything should be setup correctly just by calling "StartClientAll()". Also is there something I need to do in the "StartHostAll()" "callback", aside from sending the connect information to the clients?

    Could it be that using relay alone is not supported? It make sense to not use this plugin at all if I just want to use the relay service but I just want to confirm that it can fall back to it.
     
  47. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yeah.

    If you set the joinMatchCallback you should make sure to call networkManager.OnMatchJoined() from the callback method or lots of critical setup will be missed.

    Same deal here, make sure to call networkManager.OnMatchCreate() from the callback method you set.

    Generally you're not really meant to set these callbacks unless you specifically need to do something when a unity match is created or joined. Granted they are pretty poorly named.

    The better way is to wait on the host for:
    isDoneFetchingExternalIP == true
    matchID != NetworkID.Invalid
    netHelper.isConnectedToFacilitator == true

    That way you know you've got an externalIP, matchID, and guid from the Facilitator. Maybe I need another callback or an "isReady" property that captures all that to make it a little more straight forward.

    The client should just work, you shouldn't need the callback. You'll know it's connected when OnClientConnect() is called.
     
  48. jaglitegrann

    jaglitegrann

    Joined:
    Feb 25, 2014
    Posts:
    10
    Thank you! This made it much more clear to me and now it works as expected. :)
    I added the call to "networkManager.OnMatchCreate()" in the callback as it was the missing piece. But i will probably change it to your suggested solution instead.
    Thanks again for helping me out!
     
  49. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    NAT Traversal is on sale! Get it now for 30% off.

    Get It Here

     
    Last edited: Apr 30, 2018
  50. Hyungchoel

    Hyungchoel

    Joined:
    Mar 5, 2018
    Posts:
    1
    NATTraversal: Failed to create match. We'll still try and host but it doesn't look good.
    UnityEngine.Debug:LogError(Object)
    NATTraversal.NetworkManager:OnMatchCreate(Boolean, String, MatchInfo)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)