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

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

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

  1. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    113
    Great job! Can't wait to test it out :).

    We are currently working on our own relay server, because unity pricing of relay servers is way to expensive for our implementation of the game and the latency is also far from perfect. That's why I would like to ask you if you could implement in to your plug in possibility to change the logic which is done, when the punch through failed. Thank you and keep up the good work :)
     
  2. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    241
    Nice to know you've fixed the disconnect issue, looking forward to the next release :)

    I've just set up our own Facilitator on an Amazon EC2 server, and looks like it's working, but no information/log is shown on the facilitator itself. Is this normal? Any way to show some information when users connect to it? It would be helpful to us in order to know how many matches are being played over time.
     
  3. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    241
    Ok, the new release corrects the 3-players disconnection issue :)

    I've also tested the plugin on Mac and Linux.

    On Mac it worked fine out of the box, on Linux it failed while trying to load the RakNet.so library. I found that renaming the file to libRakNet.so was enough to fix the problem.

    However, I think only the 64-bit Linux library is included in the plugin. Any chance we can get a 32-bit RakNet.so file (or a download location somewhere)?
     
  4. Toumal

    Toumal

    Joined:
    Jun 25, 2013
    Posts:
    8
    Help, I have a problem!

    First of all let me preface this by saying that I had everything working perfectly with my custom matchmaking system, worked like a treat. However, the latest upgrade breaks my client joining:

    The function StartClientAll used to have three mandatory parameters: hostExternalIP, hostInternalIP, and hostGUID.

    Now however: StartClientAll (string hostExternalIP, string hostInternalIP, ulong hostGUID, NetworkID matchID, NetworkMatch.DataResponseDelegate<MatchInfo> joinMatchCallback)

    I have no matchid and no matchinfo because our matchmaking is very much not tied to unity in any way, and we have no intention of changing this. Would it be possible to expose a version of StartClientAll that works like in the previous releases?
     
  5. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Toumal
    This is the method definition for StartClientAll that went into the latest release:

    Code (CSharp):
    1. StartClientAll(string hostExternalIP, string hostInternalIP, ulong hostGUID, NetworkID matchID = NetworkID.Invalid, NetworkMatch.ResponseDelegate<JoinMatchResponse> joinMatchCallback = null, string matchPassword = "", int eloScore = 0, int requestDomain = 0, bool matchAlreadyJoined = false)
    It looks like only those three first parameters should be required. Everything else has a default value so you can just leave it out when calling the method. If you don't have a matchID just don't pass one in and the plugin should behave accordingly (it won't try and join a UNet match).

    @WaaghMan
    I'll look into the linux libraries when I get some free time. It shouldn't be too much trouble to add in the 32bit version. You can also always try compiling the RakNet library yourself if you get impatient :) There may also be somewhere you can download it but I haven't come across anywhere yet.
     
  6. Toumal

    Toumal

    Joined:
    Jun 25, 2013
    Posts:
    8
    Thanks a lot for the quick reply! I imported UnityEngine.Networking.Types and passed NetworkID.Invalid and null - and everything is fine again. I'm relieved that you retained independence from unity matchmaking. I should note that these parameters have no defaults in the latest release however unless you released an update today ;)

    Thanks a lot, great asset! I'm thinking of putting our matchmaking onto the asset store, they seem to work really well together!
     
    thegreatzebadiah likes this.
  7. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Oh I see where the issue is. Total oversight on my part. There are different branches of the plugin in order to be compatible with different version of Unity (5.2, 5.3, 5.4) and it seems like I added the defaults to the 5.2 and 5.3 branches but not the 5.4 branch. It's not really a huge problem or anything since as you discovered you can just pass in the default values, but I'll make sure to get it fixed in the next release anyway.
     
  8. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    242
    thanks for hooking up host migration so quickly! so far, it seems to be working quite well.

    one unrelated issue i'm having now, is being unable to do local tests on one machine. it's possible that this isn't related to updating your plugin, but i could use some help eliminating variables.

    so basically, the idea is that i have an "offline" scene where i create a localhost, so the player can run around in a lobby type environment, and mess around with various NetworkBehaviour'd objects that they'd find in a real multiplayer game. to do this, I call StartHost() to start up a local server. Once they're in this environment, they can choose to join or create a match. i borrowed some code from your examples to make this happen.

    when i'm about to exit the local server lobby scene, i call this to kill the server -

    Code (CSharp):
    1.  
    2. // (MyNetworkManager is derived from NATTraversal.NetworkManager)
    3. if (NetworkServer.active)
    4. {
    5.     NetworkServer.SetAllClientsNotReady();
    6.     MyNetworkManager.Instance.StopHost ();
    7. }
    8. else
    9. {
    10.     MyNetworkManager.Instance.StopClient ();
    11. }
    then i create or join the game based on the player's selection. this works great with two different machines, but as soon as I try to test two players on one machine, this is what happens -
    1. player one starts game, creates local server lobby.
    2. player one chooses to create a game. i clean up the localhost via my code snippet above. then i create a game through the matchmaker. he's now in a real (?) multiplayer game
    3. player two starts game, attempts to create local server lobby.
    4. player 2 can't create his local server because the port is tied up -
      Cannot open socket on ip {*} and port {7777}; check please your network, most probably port has been already occupied
      UnityEngine.Networking.NetworkManager:StartHost()
    any ideas? like i said, this might not be related to updating the plugin. i forget the exact timeline of this, but the localhost lobby stuff was added around the same time too, so it's possible i messed something up there.

    edit - i suppose for local testing, i could probably just use 2 different ports...will try that
     
  9. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    242
    ok using different ports seems to fix up my local hosting issue. however when the second player joins the game, i now see this error on the host -

    InvalidCastException: Cannot cast from source type to destination type.
    NATTraversal.NetworkManager.get_migrationManager () (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:225)
    NATTraversal.NetworkManager.OnServerConnect (UnityEngine.Networking.NetworkConnection conn) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:999)
    UnityEngine.Networking.NetworkManager.OnServerConnectInternal (UnityEngine.Networking.NetworkMessage netMsg)
    UnityEngine.Networking.NetworkConnection.InvokeHandler (Int16 msgType, UnityEngine.Networking.NetworkReader reader, Int32 channelId)
    UnityEngine.Networking.NetworkConnection.InvokeHandlerNoData (Int16 msgType)
    UnityEngine.Networking.NetworkServer.AddExternalConnectionInternal (UnityEngine.Networking.NetworkConnection conn)
    UnityEngine.Networking.NetworkServer.AddExternalConnection (UnityEngine.Networking.NetworkConnection conn)
    NATTraversal.ExternalServer.OnConnected (UnityEngine.Networking.NetworkConnection conn) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/ExternalServer.cs:35)
    UnityEngine.Networking.NetworkServerSimple.HandleConnect (Int32 connectionId, Byte error)
    UnityEngine.Networking.NetworkServerSimple.Update ()
    NATTraversal.NetworkManager+<>c.<Update>b__62_0 (NATTraversal.ExternalServer server) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:690)
    System.Collections.Generic.List`1[NATTraversal.ExternalServer].ForEach (System.Action`1 action) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/List.cs:361)
    NATTraversal.NetworkManager.Update () (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:690)

    doesn't seem like the game is completely busted so i can work around this, but maybe this error is important or fixable?
     
  10. vicwcc

    vicwcc

    Joined:
    Jul 20, 2016
    Posts:
    2
    hi, I am working on Linux project and try to make this plugin work on Ubuntu 14.04.
    I follow @WaaghMan 's advice to rename the library to libRakNet.so. Now my project can find the Raknet library but another error comes up
    Couldn't open /home/aaa/Desktop/P2P/P2P_Data/Plugins/x86_64/libRakNet.so, error: /home/aaa/Desktop/P2P/P2P_Data/Plugins/x86_64/libRakNet.so: undefined symbol: _ZpIRKN6RakNet10RakWStringES2_
    > UnityEngine.MonoBehaviour:StartCorroutine(IEnumerator)NATTraversal.NATHelper:Awake()(at E:/_Nobel Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NATHelper.cs207)
    I can't move forward unless this problem had been solved, any ideas for this?
     
  11. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    241
    Yes, I saw that error as well, but even with that it seemed to work and properly connected to the facilitator (I was only allowing connections through the facilitator to test things out)
     
  12. Jos-Yule

    Jos-Yule

    Joined:
    Sep 17, 2012
    Posts:
    292
    So, have come back around and have mostly successfully integrated the NAT Traversal stuff into our game! Awesome! Was before using just straight up UNet matchmaking/relay servers. Then integrated Steam Lobbies to pass the match info around. Now have NAT Traversal in, and it mostly works. I do get the following error which i do not understand since it relates to a match being unjoinable, which seems ... hard to believe.

    Code (CSharp):
    1. System.FormatException: FAILURE Returned from server: failed: Failed enumerating host node id appId=8801. Match is likely unavailable, please select another to join.
    2.   at UnityEngine.Networking.Match.Response.Parse (System.Object obj) [0x00000] in <filename unknown>:0
    3.   at UnityEngine.Networking.Match.JoinMatchResponse.Parse (System.Object obj) [0x00000] in <filename unknown>:0
    4.   at UnityEngine.Networking.Match.NetworkMatch+<ProcessMatchResponse>c__Iterator0`1[UnityEngine.Networking.Match.JoinMatchResponse].MoveNext () [0x00000] in <filename unknown>:0
    5. UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator0`1:MoveNext()
    6.  
    and

    Code (CSharp):
    1. JSON Response: [[UnityEngine.Networking.Match.JoinMatchResponse]-success:False-extendedInfo:failed: Failed enumerating host node id appId=8801. Match is likely unavailable, please select another to join.]-address:,port:0,networkId:0x0000000000000000,nodeId:0x0000,usingRelay:False
    2. UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator0`1:MoveNext()
    3.  
    I know i have the correct MatchID values - confirmed via debug logs on both Host and Client. The game can connect directly (when i manually open a port to test that). Just some players get this error. When i was using the standard Matchmaker/Relay we could always all join or none.

    I'm also using the StartClientAll() call with the external, internal, hostGUID, matchGUI, callback, password method. All those values are valid, confirmed on both HOST and Client via logging - passed via the Steam Lobby.

    Any hints or pointers?

    ps. the next two Errors are:

    Code (CSharp):
    1. NATTraveral: Failed to join UNET Match. We'll still try and connect but it doesn't look good.
    2. UnityEngine.Debug:LogError(Object)
    3. NATTraversal.NetworkManager:OnMatchJoined(JoinMatchResponse) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:850)
    4. UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator0`1:MoveNext()
    5.  
    and

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. NATTraversal.NetworkManager.OnMatchJoined (UnityEngine.Networking.Match.JoinMatchResponse resp) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:853)
    3. UnityEngine.Networking.Match.NetworkMatch+<ProcessMatchResponse>c__Iterator0`1[UnityEngine.Networking.Match.JoinMatchResponse].MoveNext ()
    4.  
     
  13. nottelling

    nottelling

    Joined:
    Aug 29, 2013
    Posts:
    12
    Would it be easy to make this work with UNET LLAPI?
     
  14. Somaweb

    Somaweb

    Joined:
    Feb 4, 2015
    Posts:
    14
    There seems to be an issue with Unity 5.4 and the updated NatTraversal Plugin.
    We can easily reproduce an Exception by Opening a Unet Lobby (You are the host right now), then calling DropConnection and StopHost/StopClient and then trying to open a lobby again. What we get is:

    NullReferenceException: Object reference not set to an instance of an object
    NATTraversal.NetworkManager+<StartHostAsync>d__53.MoveNext () (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:341)
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

    Thanks for having a look!
    Cheers Andi
     
  15. fgcol

    fgcol

    Joined:
    Sep 15, 2016
    Posts:
    2
    Are there any plans to support other platforms, like the PS4?
     
  16. Somaweb

    Somaweb

    Joined:
    Feb 4, 2015
    Posts:
    14
    Hey everybody, we do have quite a issue here. The Nat punch throuogh does not work sometimes and it does not change to the relay service. What we do find in some logs we get is that one connection is made using an IPv6 Adress. Any thoughts on that? Why does it not go to the relay connection once the nat punch through doesn't work?

    Thank you very much so far.

    One log looks like this:

    Object reference not set to an instance of an object
    Log: cannot connect after 10 attempt address {::ffff:185.17.206.194:7778}
    OnStopClient

    Greets Andi
     
    Last edited: Sep 20, 2016
  17. fgcol

    fgcol

    Joined:
    Sep 15, 2016
    Posts:
    2
    I'm not sure if I'm missing a step, but I can't get my Facilitator to work on my Linux server. I thought this step would be quite easy actually. All I did was copy the "Facilitator" file and change the executable bit, but what I get is a Segmentation fault (core dumped). Any ideas what I'm doing wrong?
     
  18. Reilaos

    Reilaos

    Joined:
    Jul 2, 2016
    Posts:
    10
    It seems I've been making the opposite of progress. Updated to Unity 5.4 and reimported every asset in the plugin. Now I get this, just from the build. Not even getting it to run long enough to crash anymore.


    Unhandled Exception: Mono.CSharp.InternalErrorException: Assets/Plugins/NAT Traversal for UNET/AdvancedNetworkManager.cs(5,14): AdvancedNetworkManager ---> System.TypeLoadException: Could not load type 'ResponseDelegate`1'.

    at (wrapper managed-to-native) System.Reflection.MonoMethodInfo:get_method_info (intptr,System.Reflection.MonoMethodInfo&)

    at System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) [0x00000] in <filename unknown>:0

    at System.Reflection.MonoMethodInfo.GetAttributes (IntPtr handle) [0x00000] in <filename unknown>:0

    at System.Reflection.MonoMethod.get_Attributes () [0x00000] in <filename unknown>:0

    at System.Reflection.MethodBase.get_IsVirtual () [0x00000] in <filename unknown>:0

    at Mono.CSharp.MemberCache.AddMethods (BindingFlags bf, System.Type type) [0x00000] in <filename unknown>:0

    at Mono.CSharp.MemberCache.AddMethods (System.Type type) [0x00000] in <filename unknown>:0

    at Mono.CSharp.MemberCache..ctor (IMemberContainer container) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeHandle..ctor (System.Type type) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeHandle.GetTypeHandle (System.Type t) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeHandle.GetMemberCache (System.Type t) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeManager.LookupMemberCache (System.Type t) [0x00000] in <filename unknown>:0

    at Mono.CSharp.MemberCache..ctor (System.Type baseType, IMemberContainer container) [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeContainer.DoDefineMembers () [0x00000] in <filename unknown>:0

    at Mono.CSharp.Class.DoDefineMembers () [0x00000] in <filename unknown>:0

    at Mono.CSharp.TypeContainer.Define () [0x00000] in <filename unknown>:0

    at Mono.CSharp.ClassOrStruct.Define () [0x00000] in <filename unknown>:0

    at Mono.CSharp.Class.Define () [0x00000] in <filename unknown>:0

    at Mono.CSharp.RootContext.PopulateTypes () [0x00000] in <filename unknown>:0

    --- End of inner exception stack trace ---

    at Mono.CSharp.RootContext.PopulateTypes () [0x00000] in <filename unknown>:0

    at Mono.CSharp.Driver.Compile () [0x00000] in <filename unknown>:0

    at Mono.CSharp.Driver.Main (System.String[] args) [0x00000] in <filename unknown>:0

    TypeRef ResolutionScope not yet handled (47) for .ResponseDelegate`1 in image D:\Sync\Projects\Unity Projects\Telefrag\Assets\Plugins\NAT Traversal for UNET\NATTraversalForUNET.dll
    The class ResponseDelegate`1 could not be loaded, used in ​
     
  19. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    So....as many of you seem to have figured out, the Facilitator included with the last version of the plugin is pretty broken. I've put up a working one that you can download here. Sorry for the issues and confusion.

    @Reilaos If you change your unity editor version you must also redownload the plugin from the asset store (from inside the unity editor). There are different versions of the asset for each version of the editor.

    @Somaweb I think I just emailed you about IPv6 stuff.

    Cool, should be pretty straight forward to find and fix. Thanks for the heads up.

    Usually this means the match is still listed but the host is not actually up any more. I will sometimes see this when rapidly switching from host to client while testing. If you go fast enough a client can pull down their own old match and attempt to join it which will of course fail. I've got some code in the ExampleNetworkManager that attempts to prevent that from happening but I don't think it was executing in all version of the editor so maybe that's the problem. If that is the cause then it will be fixed in the next update (which I'm putting together right now).

    @robochase re: host migration
    I've added you to a list. I'll try and look the issues soon but it probably won't make it into the update that I'm putting together right now. Thanks for the stack trace, it looks like something I'll be able to track down without too much trouble.

    Anyone who I have missed or unintentionally ignored: please post here again or contact me directly via email. I try and keep track of everything but sometimes a bug will get lost in the mix. I promise it's not intentional, if you keep bugging me it will get fixed!*

    *excluding native steam support / web sockets / mobile. It ain't gonna happen this side of 2017.
     
  20. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I think I could implement something to do what you want, but it wouldn't work quite how you're thinking. The way it works right now all of the connections are started simultaneously. It doesn't wait for the punchthrough connection to fail before attempting a relay connection. So what I think would be needed is a way for you to add "extra" connection methods that will be attempted at the same time as all the others. I'm just not sure how best to architect it though. Maybe get in contact with me via email and we can work something out.
     
  21. Reilaos

    Reilaos

    Joined:
    Jul 2, 2016
    Posts:
    10
    I'd done so thrice before posting. Just did it a fourth time. I deleted:

    Plugins/NAT Traversal for UNET/ and it's contents
    NAT Traversal Example/ and it's contents
    Plugins/RakNet.bundle and it's .meta file
    Plugins/x86/Raknet.dll, Raknet.so and their meta files
    Plugins/x86_64/Raknet.dll, Raknet.so and their meta files
    And then I reimported from the unity store.

    Is it possible that the old stuff is somehow lingering in the build? I cleared the library folder for good measure after I did the above steps. Still no go.

    Is it possible that the version I updated to is incompatible? I'm on 5.4.1f1 specifically.
     
  22. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I just installed that exact version of the editor to be sure and it seems to work fine. That is the error you get if you use the wrong version of the plugin though so I suspect you're right about something lingering. You could try deleting your ProjectSettings folder as well but you will lose lots of settings that you may not want to lose. You could maybe try just deleting the NetworkManager.asset file in the ProjectSettings folder but that's just a guess. Either way make sure you back up your ProjectSettings before you go deleting anything.
     
  23. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I think I've got a fix for you but I never actually figured out how to replicate the error so maybe you could test something for me. Can you add the line:

    matchMaker = gameObject.AddComponent<NetworkMatch>();

    after you drop the match / StopHost.

    It seems like the matchMaker gets destroyed and not recreated because I messed up and only added the check in the 5.3 code. It will be fixed in the next update that I'm putting together now. In the meantime you should be fine to just add a new NetworkMatch component like that after shutting down.
     
  24. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    This turned out to be a big source of confusion for me. It turns out what I thought was the 32bit version was just another copy of the 64bit version. This along with the naming issue will be fixed in the next update.

    I think this will be solved along with the other linux fixes in the next update but let me know if it's still not working after the update.
     
  25. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Final update for the day:

    I just finished packaging the latest update for the asset store. It should show up within 10 days (usually less).
     
  26. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Ok, I lied, one more.

    Yep, it should work out of the box. The included ExampleNATHelperOnly scene should get you started.
     
  27. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Reilaos just as a sanity check, take a look at the README that is included with the plugin and see what editor version it says at the top. I wonder if the editor is just refusing to download the right version for some reason.
     
  28. Reilaos

    Reilaos

    Joined:
    Jul 2, 2016
    Posts:
    10
    Damn. You're right. These are the first two lines:
    Plugin Version: 1.43
    Unity Version: 5.3.*​

    Now I need to figure out why I'm being given the 5.3.* version...

    EDIT:
    Through some kind of weird dance in the "downloaded plugins" folder, Unity offered to update files in the folder. Now I'm stuck on a "No overload for method `StartClientAll' takes `3' arguments" compiler error, but I'm pretty sure I've seen that problem addressed elsewhere in the thread, so I'll look for that.

    EDIT:
    I did the thing that @Toumal did, and I'm building now. Now I need to get a hold of one of my tester people... (Thanks for the suggestion, by the way!)
     
    Last edited: Sep 28, 2016
    thegreatzebadiah likes this.
  29. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I just added some links to the latest versions of the Facilitator in the first post. If anyone has been having Facilitator issues (especially segfaults) give the new versions a try.
    Thanks!
     
  30. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Version 1.44 released

    The Facilitator is finally fixed! For anyone wondering, the problem turned out to be Filezilla corrupting the files when transfering them to my pc. If you're reading this and you use Filezilla you may want to consider changing your default transfer type to binary instead of ASCII. *shrug* If it ain't one thing it's another.

    Changes include:
    • New version of Facilitator that works on newer versions of linux and doesn't segfault.
    • Added missing 32bit raknet linux library.
    • Improved Facilitator output to be less confusing and more useful.
    • Fixed problem disconnecting and reconnecting in 5.4 due to missing matchMaker component.
    • Fixed missing defaults for StartClientAll in 5.3
    • Updated documentation.
    • Probably more things.
    Coming soon:
    • Improved IPV6 support
    • Fix that one host migration bug
    As always thanks for reporting bugs and for bearing with me while I fix them. If you haven't rated / reviewed the asset please do so!

    Cheers.
     
  31. Reilaos

    Reilaos

    Joined:
    Jul 2, 2016
    Posts:
    10
    Progress for me! Kinda. Sorry to keep bothering like this. Updated to 1.44 (made sure it took in the README.md this time).

    Hosts still seem to only acknowledge clients in saying that their disconnections timed out.

    Clients seem to think the whole thing has gone rather well, until they get timed out and crash. It appears to be crashing in a different function than it had been previously, though.



    NATTraveral: Attempting to connect directly: xx.xxx.xx.xx xxx.xxx.x.xx

    (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)

    NATTraveral: Attempting to connect through hole xx.xxx.xx.xx:xxxxx

    (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)

    NATTraveral: Client connected via NAT punch-through

    (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)

    NATHelper: Connected to Facilitator: 1067353280239683320

    (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)

    NATHelper: NAT Device not found

    (Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 42)


    Log: connection {1} has been disconnected by timeout; address {::xxxx:xx.xxx.xx.xx:xxxxx}
    Log: cannot connect after 10 attempt address {::xxxx:xx.xxx.xx.xx:xxxx}
    Unloading 3 Unused Serialized files (Serialized files now loaded: 0)
    Crash!!!​

    Skip a bit, it's basically a huge list of .dlls

    ========== OUTPUTING STACK TRACE ==================

    0x00000001800C9DD1 (RakNet) CSharp_RakPeerInterface_IsActive
    0x0000000004CC9A4A (Mono JIT Code) (wrapper managed-to-native) RakNet.RakNetPINVOKE:RakPeerInterface_IsActive (System.Runtime.InteropServices.HandleRef)
    0x0000000004CC99A8 (Mono JIT Code) RakNet.RakPeerInterface:IsActive ()
    0x0000000004CC9907 (Mono JIT Code) NATTraversal.NATHelper:StopPunchingThrough ()
    0x0000000004CC7DE5 (Mono JIT Code) NATTraversal.NetworkManager:OnMultiClientDisconnect (UnityEngine.Networking.NetworkConnection)
    0x0000000004CC7A46 (Mono JIT Code) NATTraversal.NetworkManager:OnMultiClientDisconnectMsg (UnityEngine.Networking.NetworkMessage)
    0x0000000004CB410E (Mono JIT Code) UnityEngine.Networking.NetworkConnection:InvokeHandler (int16,UnityEngine.Networking.NetworkReader,int)
    0x0000000004CB3FAC (Mono JIT Code) UnityEngine.Networking.NetworkConnection:InvokeHandlerNoData (int16)
    0x0000000004CAF6A5 (Mono JIT Code) UnityEngine.Networking.NetworkClient:Update ()
    0x0000000004CAE605 (Mono JIT Code) UnityEngine.Networking.NetworkClient:UpdateClients ()
    0x0000000004CAE35A (Mono JIT Code) UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate ()
    0x0000000004C00553 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void (object,intptr,intptr,intptr)
    0x00007FFFF5464FFB (mono) mono_set_defaults
    0x00007FFFF53B8341 (mono) mono_runtime_invoke
    0x00007FF79E09517D (Build_Latest) ScriptingArguments::AddString
    0x00007FF79E4A7F58 (Build_Latest) RectT<int>::Reset
    0x00007FF79E0667E0 (Build_Latest) CallbackArray1<bool>::Invoke
    0x00007FF79E123050 (Build_Latest) Object::GetInstanceID
    0x00007FF79E12384A (Build_Latest) PlayerMainWndProc
    0x00007FF79E126BEE (Build_Latest) PlayerWinMain
    0x00007FF79E5DC344 (Build_Latest) RectT<int>::GetYMax
    0x00007FF82D428364 (KERNEL32) BaseThreadInitThunk

    ========== END OF STACKTRACE ===========

    **** Crash! ****​
     
  32. Ali_V_Quest

    Ali_V_Quest

    Joined:
    Aug 2, 2015
    Posts:
    138
    Great plugin
    just wanted to add my vote for mobile support, it will be really great to have it
     
    VOTRUBEC likes this.
  33. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    98
    Just to echo what's already been brought up, mobile support would be awesome.
     
  34. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    241
    I think the latest version (thank you for the update) introduces a new issue:

    We're currently working on rejecting player connections when a game is in progress, by starting a coroutine and disconnecting the client with the following code:

    Code (csharp):
    1.  
    2.  
    3.     IEnumerator RejectConnection(NetworkConnection conn)
    4.     {
    5.         yield return new WaitForEndOfFrame();
    6.         Debug.Log("Rejecting connection " + conn.connectionId);
    7.         conn.Disconnect();
    8.     }
    9.  
    10. public override void OnServerConnect(NetworkConnection conn)
    11.     {
    12.         if (!AllowJoinInProgress && sessionState == SessionState.Playing)
    13.         {
    14.             Debug.Log("Game already in progress, kicking player");
    15.             StartCoroutine(RejectConnection(conn));
    16.          
    17.             //conn.Disconnect();
    18.          
    19.             return;
    20.         }
    21.  
    22.       // rest of connection logic, etc...
    23. }
    24.  
    This means both connection attempts (direct and punchthrough) will properly get rejected on the server, but on the client, the plugin crashes with a nullreferenceexception on the replaceConnection method, I guess because the direct connection was established and closed before the punchthrough connection was established, or something like that.

    This prevents the disconnection events from being called on the client, so it still thinks it's connected to the game and bad things start to happen.

    It seems like this code worked on the previous version of the plugin, but I'm not 100% sure.

    While this is a bit of an edge case (we don't make it easy to join games in progress, but it can happen with the right timing), it would be great if it can be fixed.

    If I disable punchthrough on the connection settings, it works as expected.
     
    Last edited: Oct 5, 2016
  35. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    241
    Another issue we just found: If you exit the game (via Alt-F4, for example) right after creating a session (maybe joining as well), the game freezes and doesn't exit properly.

    We found that adding the following code on our NetworkManager fixes the issue:

    Code (csharp):
    1.  
    2. void OnDestroy()
    3.     {
    4.         NATTraversal.NATHelper helper = GetComponent<NATTraversal.NATHelper>();
    5.         if (helper != null && !helper.isDoneFindingNATDevice)
    6.             helper.stopPortForwarding();
    7.     }
    8.  
    It seems a thread is launched to look for NAT devices and if the app tries to quit while this thread is still running, bad things happen.
     
    thegreatzebadiah likes this.
  36. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    987
    I've uploaded the Facilitator file to my linux server root but I don't know how to run it. Typing the name of the file into the command prompt give this error:

    Facilitator
    root@localhost:~# Facilitator
    -bash: Facilitator: command not found
     
  37. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    303
    @spinaljack
    The command should be "./Facilitator" (without quotation mark,note on linux or *nix filename is case sensitive" so please make sure the file name is correct"
     
  38. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    987
    Thanks, I'm logged in as root but now it says "Permission denied"

    root@localhost:~# ./Facilitator
    -bash: ./Facilitator: Permission denied
     
  39. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    303
    @spinaljack
    Try command "chmod u+x Facilitator" and re-run Facilitator, what i have forgotten was i think you should have mono already installed to run the Facilitator, i haven't get simple nat traversal but afaik if it's a mono/.net executable you need to install mono and run it with "mono Facilitator", if it's a c/c++/go executable then you need to do "chmod u+x Facilitator" and run it again with "./Facilitator".
     
  40. yuchun1108

    yuchun1108

    Joined:
    Aug 5, 2014
    Posts:
    1
    I need some help.

    I am using Version 1.44 and trying the Host Migration with NAT Traversal Example.

    When I pressed "Reconnect To New Host", I always got an error:
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.Networking.NetworkClient.ReconnectToNewHost (System.String serverIp, Int32 serverPort) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:176)
    3. ExampleMigrationManager.OnGUIClient () (at Assets/NAT Traversal Example/ExampleMigrationManager.cs:118)
    4. ExampleMigrationManager.OnGUI () (at Assets/NAT Traversal Example/ExampleMigrationManager.cs:26)
    I noticed that after I call the FindNewHost(), the newHostAddress was always null.

    And the code in ExampleMigrationManager.cs at line 118
    Code (CSharp):
    1. client.ReconnectToNewHost(newHostAddress, networkManager.networkPort);
    dosen't it need the parameters "hostExternalIP", "hostInternalIP", "hostGUID", like the funcion StartClientAll()?
     
  41. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    987
    This worked thanks :)
     
  42. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    74
    Hi @thegreatzebadiah,
    I cannot get the NAT to work, even in the example scene. I can connect the clients using the relay, but not with it disabled. I even see them connect on my facilitator, but they cannot reach each other with NAT.

    I keep getting this error: NATHelper: NAT Device not found:

    I even tried to make a directory as same as the one in the error, but do not work.
    How do I fix it?
     
    Last edited: Oct 10, 2016
  43. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    987
    Okay, I've got the facilitator running but I can't get my game to connect to it. It always says failed to connect to Facilitator no matter where I try it from for both my own server and the one you provide. Any help?
     
    akuno likes this.
  44. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    230
    Is there a way to use NetworkLobbyManager with NAT Traversal?
     
  45. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    303
    IMHO you need to add it to ip table if you are using linux, try check it www.canyouseeme.org first, check if the port and ip really works and open first.

    Which linux distro & version are you using?
     
  46. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    74
    Does your server is behind a firewall? Or behind a router with no port fowarding?
     
  47. Ranger-Burke

    Ranger-Burke

    Joined:
    Oct 7, 2015
    Posts:
    11
    Just grabbed and installed this... but I don't get OnMatchJoined after the client joins after calling StartClientAll(match, OnMatchJoined); in the successful OnMatchList callback, defined as

    public override void OnMatchJoined( bool success, string extendedInfo, MatchInfo matchInfo) {
    base.OnMatchJoined(success, extendedInfo, matchInfo);
    Debug.Log( "On Match Joined");

    The connection is made, and then host and client pass messages back and forth, but I'm scared of missing a vial callback.

    Any hints?
     
  48. Ranger-Burke

    Ranger-Burke

    Joined:
    Oct 7, 2015
    Posts:
    11
    Grabblesgame worked for me a few days ago when I first grabbed the package, but it started also failing for me this week. I put up a facilitator on ec2 and it runs fine. Where are you hosting your facillitator? What are your security settings?

    There was some instruction to use the IP/Port returned by running ./Facilitator, but that was the internal ip for ec2, so I just used the normal ip4 in the title and it worked fine.
     
  49. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    987
    I got a virtual server from 1and1.co.uk which has a public ip address. I'll use that website to check the port is open but it should be.

    EDIT:
    Server OS: Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-21-generic x86_64)

    I'm using the 512MB RAM VPS from here:
    https://www.1and1.co.uk/virtual-server

    I just tried to ping it with no success so maybe it's not accepting incoming connections.

    I tried using iptables but I don't think it's installed cos it says command not found.
     
    Last edited: Oct 12, 2016
  50. SweatyChair

    SweatyChair

    Joined:
    Feb 15, 2016
    Posts:
    140
    Hi,

    We are a mobile game indie and very interested in getting this awesome plugin.

    Same to most people, we would like to know if the mobile will be supported!

    Or, is that been implemented already? I am bit confused as in document you said:
    I suspect this works on mobile but I haven't had a chance to test it yet. It should work on any platform that RakNet works on as long as it has real sockets.