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:
    748

    Adds NAT punch-through and automatic port forwarding to any peer-to-peer networking API​

    Reduces latency and saves you money by connecting players directly whenever possible, even behind a router.

    You only need three methods: StartHostAll(), listMatches(), and StartClientAll() to connect.

    Falls back to Unity's relay servers only if punch-through fails, so players can always connect.

    Works on Windows, Linux, and OSX

    Asset | Docs | API | FAQ | Demo

    Direct connect whenever possible
    Why waste your hard earned money using bandwidth on the relay servers if you don't have to? A direct connection means less lag and less dependence on infrastructure that you don't control.

    Seamless connection replacing
    Your players will always use the best connection possible, seamlessly switching from relay to direct connections as they become available.

    Faster connection
    Gets your players in the game faster by not waiting for a UNET match to be created or joined before connecting.

    Set client connect port
    Includes the ability to set the port that clients connect from. Just in case you need that.

    Note: Punch-through requires an externally hosted server to run the included Facilitator on.

    Note: Web builds are not supported. Unfortunately the library we use (RakNet) does not work with WebSockets. Sorry!

    Demo video

    Tutorial

    But Why?

    The primary motivation for creating this was so that I could be less dependent on Unity's relay servers. For one, they are bandwidth restricted, and they seem to introduce some pretty high latency. Plus it's just one more point of failure that us lowly developers have absolutely no control over. This solution should mean that connecting through Unity's relay servers is almost never necessary.

    Requirements
    Unity 5.2 or above. Tested in 5.2.0f2, 5.3.0f4, 5.3.4f1, 5.3.5f1, 5.4.0b3, 5.4.0b15, 5.4.0b22, 5.4.1f1, 5.5.0f3, 5.6.0b11, 5.6.2f1, 2017.1.0f3

    The Facilitator
    There are two versions of the Facilitator packaged with the plugin. One for windows and one for linux. You can also always get the latest versions below:

    If you have any questions just let me know. I hang around in the forums all the time. I'm also always available at the support email. I'm actively developing this plugin for use in my own game so I respond to issues / put out fixes quickly.

    Thanks!

    Also check out our other plugin to smoothly sync transforms and rigidbodies over the network: Smooth Sync
     
    Last edited: Oct 6, 2018
  2. Fsilva

    Fsilva

    Joined:
    Mar 31, 2015
    Posts:
    30
  3. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    I haven't tested with UNET 'Server + MySQL and Clients' but by reading the description it seems like it should work. I'm using mysql right now in my own project to store the matchID and raknet guid so there's definitely no problem integrating with mysql.

    I hadn't considered integration with PlayMaker or ICode but it's something I can look into.
     
    Fsilva likes this.
  4. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    Version 1.2 has been released into the wild!

    Changes include:
    • Simplified interface: I made a couple more parameters optional in the StartHostAll() and StartClientAll() methods so that it is even easier to set up.
    • Cleaned up some logging: Because who doesn't like helpful error messages
    • Fixed an issue with disconnecting and reconnecting: This was a legit bug that would occur if a client disconnected from the host and the reconnected to the same host. Now fixed.
    • Made some harmless error messages go away: Unity was throwing a couple of harmless errors because of some functionality that I overrode / extended. I made the errors go away.
    • Fixed an error that could be thrown if the game is stopped immediately after running: Yep.
    I've heard back from a couple of people who have tried the asset and reported that the punch-through is properly punching and letting them connect through routers no problem. It's really great hearing the sense of relief from happy devs finally able to get their players directly connected :)
     
    moco2k likes this.
  5. MatiasJP

    MatiasJP

    Joined:
    Nov 4, 2013
    Posts:
    16
    This is fantastic, it could be the thing that I was looking for.

    A noob question, with this NAT punch through can I do a game for PS4 using the PS4 network without the CCU charge or the PS4 network use other kind of port forward?
     
  6. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    I'm afraid I'm just not knowledgeable enough to answer your question very well, but I think the way it works is that sony provides their own nat-punchthrough / port forwarding / relay infrastructure so you don't have to use Unity's anyway. And I think it's probably free. I'm really guessing here though so don't take my word on it. I'm mostly going off of how steam works and what little I know of how xbox works.

    Of course the advantage of sticking with the UNET infrastructure (with my plugin) is that you could (ideally) use the exact same infrastructure / network code on all platforms, unfortunately I'm not really sure if this is something sony or microsoft will allow. They may force you to use their own infrastructure, or at the very least they will make you jump through some hoops to be able to host your own Facilitators.

    My studio is working on getting our own game out on the consoles as well so I'll have some more concrete answers in the future when we start working on the console ports, but as of right now I don't think I would recommend using this plugin if the only platform you are releasing on is ps4.
     
  7. MatiasJP

    MatiasJP

    Joined:
    Nov 4, 2013
    Posts:
    16
    Thanks for the fast, honest and detailed answer!. In any case I'll buy the assets in order to test my moba for pc, thanks again!
     
    thegreatzebadiah likes this.
  8. tenttu

    tenttu

    Joined:
    Sep 22, 2015
    Posts:
    19
    Is there an option to define which relay server is used? As in case you didn't know, players from different relay servers can't connect with each other. There are currently three different matchmaking/relay servers located in US, Europe and Asia. It would be required to manually set the relay server, if the match comes from any external matchmaking source (like Steam server listing etc.)
     
  9. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    Yeah, it works exactly like the normal NetworkManager provided by unity. You can either set the matchHost in the inspector or from a script.
     
  10. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    Hello!

    You are not 100% on how well this will work with OSX. Could you add some more details about Mac/OSX support, since that is a platform which we are supporting?

    Thanks!
    Jos
     
  11. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @Jos Yule Sorry for the delayed response. OSX support is something I was actively working on so I didn't want to say one way or the other until I figured it out.

    I am very happy to announce that OSX is now fully supported. I'm packaging the update right now. It will be available on the asset store in 5-10 days.

    I will make sure to update all of the documentation accordingly.
     
  12. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    Version 1.3 is now live. This a pretty big update, including some new videos to help you get started using the plugin.

    Changes include:
    • Added support for OSX
    • Fixed hostInternalIP and hostExternalIP not being set on the host
    • Added the option to disable unity matchmaking so that it can be replaced with other matchmaking systems such as steam lobbies.
    • New demo video
    • New tutorial video
    • Updated documentation
    Check out the new videos below:

    Demo


    Tutorial
     
  13. metalkat

    metalkat

    Joined:
    Feb 19, 2011
    Posts:
    26
    Well, this looks handy, maybe a video explaining some of the magic? because this looks kind of "too good to be true" (?)
     
    thegreatzebadiah likes this.
  14. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @metalkat I assure you it's not magic, though I'm flattered that you think so :)

    Maybe it will help ease your mind a bit to know that the plugin is built on two very solid and proven technologies. The automatic port forwarding is provided by Open.NAT and the punch-through is done using RakNet, which is actually the library that Unity's own networking was based on before the switch to UNet.

    You may remember the Facilitator from the pre-UNet days. That was how people got connected before the relay servers were a thing. My plugin basically brings back that functionality to UNet.
     
    metalkat likes this.
  15. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    @thegreatzebadiah Great news about OSX support. Just bought it, got the Facilitator running @ EC2, demo scene working great. Would like an example or hint of how to remove the Unity Matchmaker - we are currently using the Steam Matchmaking API, but just a generic "how to swap for Unity Matchmaker for generic replacement" pointer would be be great.

    Thanks for the excellent update,
    Jos
     
  16. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    Further - my ideal setup is to use Steam's matchmaking, but still have access to Unity's relay service, for the cases where Upnp & Punch-Through fail. :)
     
  17. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    Hurm, i also see that this is a NetworkManager replacement - i'm making use of the NetworkLobbyManager, and particularly the lobby join/switch callbacks, to pass data from the lobby player to the network player... Have to figure out how to replicate that functionality.
     
  18. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @Jos Yule

    The steam stuff should be super easy. All you need to do is uncheck Use Unity Matchmaking and instead use a steam lobby to pass around the host's connection info.

    After you call StartHostAll() when you receive the callback to OnMatchCreate() you should create a steam lobby and add the host's connection info as lobby data.

    SteamMatchmaking.SetLobbyData(steamIDLobby, "matchID", createMatchResponse.networkId);
    SteamMatchmaking.SetLobbyData(steamIDLobby, "guid", NATHelper.guid.ToString());
    SteamMatchmaking.SetLobbyData(steamIDLobby, "publicIP", externalIP);
    SteamMatchmaking.SetLobbyData(steamIDLobby, "internalIP", internalIP);

    Clients can then find and join the steam lobby using the steamworks api as normal. Once they are in a lobby they read the host's connection info from the lobby data and pass it to StartClientAll().

    The relay servers are still used as a fallback (as long as you don't uncheck Connect Relay) so it should do exactly what you want.

    As for the NetworkLobbyManager...I'm not so sure. I've never used it myself so I'll have to look into it a bit and see if I can get it working with the plugin. That being said, the NetworkManager provided by the plugin extends from Unity's built-in NetworkManager so it's probably not that far off.
     
    Last edited: May 2, 2016
  19. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    Thanks for the pointers to using the Unity Matchmaker with the steam stuff - that is way easier then i thought it would be!

    WRT the lobby, the idea is that there is a "lobby" player prefab, and a lobby scene, which is NOT the game itself, where you can set up all your pre-game stuff, and then move to the game scene, which is when the network player prefab is created. You then get a callback with the lobby player prefab and the network player prefab (instances), so you can copy/update the data/setup from the lobby into the "real" player. The only thing we are doing in the lobby is setting up the controller stuff the player is using, so we could probably drop using it, honestly...
     
  20. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    The NetworkLobbyManager seems like something I can get working, but I can't say how soon. I'm packaging up the next update right now so it won't make it into this one at least.

    In the meantime maybe you can try copying and modifying the code for NetworkLobbyManager.
    Create a new script (AdvancedNetworkLobbyManager maybe), paste in the code, and where it extends from NetworkManager change it to extend from NATTraversal.NetworkManager instead.
    Then wherever you are using the NetworkLobbyManager instead use the new AdvancedNetworkLobbyManager script you just created. That should at least give you access to the functionality provided by the plugin, but I have no idea if it will play nice with everything else in the lobby manager.

    If by some miracle that works flawlessly please do let me know. I always love to get good news :)
     
    Last edited: May 3, 2016
  21. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    That was exactly what i was going to try. Will let you know how it goes.
     
  22. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    Ok, so i have it compiling with no errors - haven't tested it yet.

    In the AdvancedNetworkLobbyManager I had to add the following class (inside the names space i was using for the ANLM), as it was internal and couldn't be found otherwise.

    Code (csharp):
    1.  
    2. class LobbyReadyToBeginMessage : MessageBase
    3. {
    4.  public byte slotId;
    5.  public bool readyState;
    6.  
    7.  public override void Deserialize(NetworkReader reader)
    8.  {
    9.    slotId = reader.ReadByte();
    10.    readyState = reader.ReadBoolean();
    11.  }
    12.  
    13.  public override void Serialize(NetworkWriter writer)
    14.  {
    15.    writer.Write(slotId);
    16.    writer.Write(readyState);
    17.  }
    18. }
    19.  
    Also, due to a method on the NetworkConnection being internal (GetPlayerController), I had to add this extension class - it is a horrible hack, but had to be done to get it to compile.

    Code (csharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.Networking;
    4. using System.Collections;
    5. using System.Reflection;
    6.  
    7.  
    8. public static class NetworkConnectionExtensionMethods {
    9.  
    10.  public static bool GetPlayerControllerExtension(this NetworkConnection value, short playerControllerId, out PlayerController playerController){
    11.    MethodInfo dynMethod = value.GetType().GetMethod("GetPlayerController",
    12.    BindingFlags.NonPublic | BindingFlags.Instance);
    13.  
    14.    object[] parameters = new object[]{ playerControllerId, null };
    15.    object result = dynMethod.Invoke(value, new object[] { parameters });
    16.    bool blResult = (bool)result;
    17.  
    18.    playerController = blResult ? (PlayerController)parameters[1] : null;
    19.  
    20.    return blResult;
    21.  }
    22. }
    23.  
    Three places in AdvancedNetworkLobbyManager had to have their calls to GetPlayerController changed to GetPlayerControllerExtension.

    That was it, which was better then I expected.

    Will try this out on otherwise working code tomorrow.
     
  23. voltage

    voltage

    Joined:
    Nov 11, 2011
    Posts:
    493
    So this comment perked my ears. I want to create online multiplayer without a matchmaking service whatsoever. I still want a Local Client + Remote Client relationship. (No dedicated servers). But when players type in their friend's IP address to connect, your asset will circumvent their router so the connection works. Is this possible?

    I'm trying to avoid monthly payments any way I can, while still having a functioning online multiplayer feature for my games. Thanks for your time.
     
    ricna-net likes this.
  24. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    @voltage I am not the developer, this is only my 2 cents, YMMV, take with a grain of salt, etc etc, but, yes, that is what this asset does. It tries to use UPNP to create port-forwarding entry on the hosts router, and if that fails, tries to do NAT Punch-through. You don't have to enable the use of Unity's Relay service if you don't want to. NOTE that NAT Punch-Through does require you to run an app on a server someplace. I've got it hosted on an Amazon EC2 instance. I figure it will cost about 5 bucks a month to host it there.

    I'm sure @thegreatzebadiah will have more accurate info for you too.

    Peace
     
  25. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @Jos Yule Cool, that's about what I expected (a little worse actually). I've unfortunately had to use a number of similar hacks in the plugin to be able to get UNet to do what I want. It's really a shame Unity doesn't expose more of the internals so that it's easier to override and extend stuff.

    @voltage Yep, this plugin will do exactly what you're looking for, but you'll need more than just the IP to connect. You'll also need the RakNet guid since it is needed for punchthrough to work, but it's the same concept. You just pass the host's IP and guid into StartClientAll() and it will connect. And as @Jos Yule mentioned you do have to host the Facilitator somewhere so that players can connect to it to get their guid and do the punch-through magic. AWS is free for the first year though at least.
     
  26. maglat

    maglat

    Joined:
    Jul 9, 2010
    Posts:
    110
    Hey hey,

    Your asset looks very promising! Before buying it, I have two questions.
    1. Is there IOS and Android (Mobile) support?
    2. Which (cheap) server provider you recommend for running the Facilitator? What do you think about Amazon EC2?

    Best Regards
     
  27. Aithoneku

    Aithoneku

    Joined:
    Dec 16, 2013
    Posts:
    65
    For some reasons, I have to use copy of the NetworkLobbyManager so thank you for this hack (although I honestly hope I will be allowed to not use the copy of NLM because of it's limitations and the hack). However, I encountered a problem:

    Code (csharp):
    1.  
    2. // This didn't work for me:
    3. object result = dynMethod.Invoke(value, new object[] { parameters });
    4.  
    5. // This fixed it:
    6. object result = dynMethod.Invoke(value, parameters);
    7.  
     
  28. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    Nice catch. I was under the influence of a 24 hour flu yesterday, and so wasn't able to test it out, this will help me today, thanks!
     
  29. Aithoneku

    Aithoneku

    Joined:
    Dec 16, 2013
    Posts:
    65
    NP and btw. - it seems that rest of the copy of network lobby manager works well. One thing though - Unity's NetworkLobbyPlayer references original NetworkLobbyManager, so it doesn't work with the copy. Fix is simple - copy also player's source code and update referenced types. The player also uses protected message classes (LobbyReadyToBeginMessage and IntegerMessage), but that can be fixed by just copying messages code. And in case of player, there is no need to hack access to some internal methods.
     
  30. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    Dang, i now see that NLM also has a custom editor, and so you can't set some of the properties in the editor - like the player lobby prefab. Hurm. I got the editor code, and assigned it to the ANLM, but that just makes _nothing_ show up in the inspector. Might have to add a helper class to set the values of the ANLM...
     
  31. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    @thegreatzebadiah How do you get the internal IP for setting in the steam lobby? Also, the createMatchResponse.networkId is an enumeration (i think), so are you casting it to a string or using the .ToString() method on it?
     
  32. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @maglat
    Not yet, but it's something I'd like to look into in the future. No timeline yet though unfortunately. I'll make sure to post an update once I get started on it.

    I'm a big fan of AWS. It's free for the first year and super cheap after that. The Facilitator uses very few resources in terms of ram / cpu / bandwidth so almost any hosting will do.

    @Jos Yule
    I get the internal IP from Network.player.ipAddress. I am casting the networkId to a string in a few places using the ToString() method. I believe internally it is either a long or ulong if that helps you out any though.
     
  33. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
  34. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    106
    @thegreatzebadiah
    my server have three ip, only one is external ip .But facilitator exe is not config external ip, your facilitator auto read local ip. please help me! thanks!
     
  35. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @LostPanda I think even though it shows the local IP when you start it up you can still use the external IP to connect. Let me know if this is not the case though. I've got an alternate way of getting the IP that I can switch to that might work better for you if you're not able to connect. I'll just have to compile a new Facilitator for you and it will be a bit experimental.

    What hosting provider are you using?
     
  36. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    106
    thanks! this cmd windows: 001.png 001.png
     
  37. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @LostPanda I see that it's showing the local IP, but try putting the external IP into the NetworkManager in unity anyway and see if it will connect. I know it's confusing, but I see something similar when I run the Facilitator on Windows but I am still able to connect to it using the external IP.

    Also, the Facilitator is not normally meant to be run on the same computer as any of the players (if that's what you're doing here). You may be able to get a client to connect to the Facilitator with it running on the same pc but I don't think the actual punchthrough will work properly unless the Facilitator is running on a separate server.
     
  38. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    106
  39. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    274
    @thegreatzebadiah Ok, i think i've messed something up. I've unchecked the "Use Unity Matchmaking" and am using
    Code (csharp):
    1. MyNetworkManager.StartHostAll("none", 16); // MyNetworkManager extends  NATTraversal.NetworkManager
    I never get the callback in MyNetworkManager's 'OnMatchCreate' override method... I've also tried adding an explicit callback in the StartHostAll() method, but that also didn't fire. (This is trying to use the Steam Match Maker to pass the info around, as described in your post above)

    Any suggestions? Thanks!
     
    Last edited: May 5, 2016
  40. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    I just double checked the code and if you have either "Connect Relay" or "Use Unity Matchmaking" enabled it should be creating the match and you should get the callback. If that's not the case it may be a bug.
     
    Last edited: May 5, 2016
  41. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @Jos Yule I think I already see the bug. connectRelay is getting set to false when you run the game right? Send me a message when you get this and I'll send you a fresh dll that should fix the problem. The fix will also be in the next update which is coming soon.
     
  42. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    Version 1.31 released

    This is another big update with lots of improvements to stability, especially when disconnecting and reconnecting.

    Changes include:
    • Refactored registerHandlerAll() to RegisterHandlerClient() to be less confusing.
    • Fixed bug caused by connections not being removed from a list when disconnecting.
    • Added ability to set the port that the Facilitator runs on.
    • Normalized line endings to make some warnings go away.
    • Reworked punch-through to fix problems with disconnecting and reconnecting to the same host.
    • Fixed an error not being properly caught in cases where the Facilitator can not be connected to.
    • Fixed OnClientConnect not being called after loading the onlineScene.
    • Added matchID and matchmakingNodeID to make it easier to disconnect from a match.
    • Fixed an issue where turning off unity matchmaking would unintentionally also disable use of the relays entirely. @Jos Yule this one's for you
    • Updated documentation.
    I've received so much great feedback here (and elsewhere) that has helped me quickly iterate on the plugin. I think it's come a long way in just a month and I couldn't have done it without the help of people here on the forums.

    Thanks everyone!
     
    Last edited: May 5, 2016
  43. voltage

    voltage

    Joined:
    Nov 11, 2011
    Posts:
    493
    Hi again TheGreat,

    I'm new to this so I'm still skeptical of my ability to make use of it. Would you mind making a short tut video on how the facilitator works? From my current understanding, this .exe will only pass IPs and ports I specified beforehand? Does that mean this will only work for personal use and not an audience on Steam? If the latter, that would infer this one executable will pass data for every player who uses this game and wants to connect to their own friends? Could I host this myself if I didn't want to pay someone for testing?

    Thanks again for the quick feedback. I'm very close to purchasing this, I just need to know what I'm doing. lol
     
  44. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    If you mean how to use it then it would be a very short video. You really just put it on a server and run it. If you mean how it works...well that's really pretty complicated.This is the best explanation I've found: http://www.raknet.net/raknet/manual/natpunchthrough.html
    The really short version is this: Players connect to the Facilitator to pick which port to connect on. This gets around port forwarding issues because reasons.

    The direct connect port is specified in the NetworkManager settings like normal and this port is automatically forwarded for you. Also when connecting via the Facilitator each player will be assigned the ports to connect on and these ports will also be forwarded. All of that happens behind the scenes though so you don't have to worry about any of it and you shouldn't ever have to manually set a single port if you don't want to.

    Same with the IP, if you're using the unity matchmaking it is all handled automatically. The host stores their connection info (including IP address) in the match when it is created. The clients pull down the match list, pick a match, and use the connection info to connect.

    The only thing you actually have to worry about doing is calling StartHostAll() on the host. The clients pull down a list of matches like normal and pass one of them into StartClientAll(). The rest is automatic.

    The plugin is absolutely intended for full release on steam or otherwise.

    The Facilitator doesn't actually pass any data other than the ports to connect on so very little bandwidth is used even with many concurrent players. The only time anything is sent or received from the Facilitator is once when the NetworkManager is first initialized and one more time whenever a player connects to a host. Once the Facilitator has done its job all the actual networking data passes straight from one player to another.

    In theory yes. You just need a computer that is hooked up to the internet and not behind a router or weirdly firewalled. Generally that means paying for a separate / business internet line though so you're paying one way or the other. In practice I recommend hosting on AWS. It is free for the first year and very reasonably priced after that.

    Hopefully things are a bit more clear now. Let me know if all that left you with more questions than aswers :)
     
    Last edited: May 8, 2016
  45. voltage

    voltage

    Joined:
    Nov 11, 2011
    Posts:
    493
    Thank you very much TheGreat. That was extremely helpful. I purchased your asset!

    So I've made an account with AWS EC2 and I made a remote client connection to control the server. I quickly learned their web surfing is very limited. Everything is blocked and requires permissions to access. I uploaded the windows nat facilitator to my dropbox in-order to get it on the server, but it wouldn't let me download it. Something along the lines of 'Security settings won't allow you to download'. I even disabled the firewalls, nothing. So for now I stopped the instance and figured you could give me good feedback.

    By the way, should I have the firewall settings disabled when I want random players across the globe connecting? (I assumed so, because I don't want a NAT blocking incoming requests).
     
  46. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    For moving the Facilitator to your server I recommend something like Filezilla to transfer it over via ftp or sftp. You definitely want the firewall disabled on the server that is hosting the Facilitator or you at least need to somehow make an exception for the Facilitator.
     
  47. brainz12345

    brainz12345

    Joined:
    Dec 10, 2012
    Posts:
    12
    Hello,

    Thanks for creating this tool, we've found it very useful, now, we're trying to compile our project for iOS and the following error is raised:

    3119: [Unity] ArgumentException: The Assembly Open.Nat is referenced by NATTraversalForUNET ('Assets/Plugins/NAT Traversal for UNET/NATTraversalForUNET.dll'). But the dll is not allowed to be included or could not be found.
    3120: [Unity] UnityEditor.BuildPipeline:BuildPlayerInternalNoCheck(String[], String, BuildTarget, BuildOptions, Boolean, UInt32&)
    3121: [Unity] UnityEditor.CloudBuild.Builder:Build()
    3122: [Unity] Error building Player: Extracting referenced dlls failed.
    3123: [Unity] (Filename: Line: -1)

    Do you have any idea what could be missing?
     
  48. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    The plugin does not support iOS at the moment. I think all that is needed is the RakNet dll compiled for iOS. There is some documentation on it here: http://www.jenkinssoftware.com/raknet/manual/compilersetup_xcode.html if you want to try and blaze that trail yourself.

    Unfortunately as-is the plugin only supports desktop platforms (Windows, Linux, Mac). I'll be doing another pass over the Mac stuff sometime this week so maybe I can look into it then. I don't actually have an iPhone to test with though (which is the only reason I haven't already done it). I may be able to find one to borrow but maybe you could also help me out with testing once I've got something put together?
     
  49. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    748
    @brainz12345 I just noticed the error you're getting is actually because of the Open.NAT dll. You could try fiddling with the import settings on the Open.NAT.dll file so that it is included in ios builds. That particular dll should work on all platforms so I think it's just a matter of the import settings being wrong. I still think you're going to have trouble with the RakNet.dll though unfortunately.
     
  50. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    250
    Big Thanks. Please ping us if you need any testing from our end. Question, if we leave Relay enabled, will the system try to do direct and then nat and then finally if there is no alternative, use the relay server?