Search Unity

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

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

  1. Barkers-Crest

    Barkers-Crest

    Joined:
    Jun 19, 2013
    Posts:
    159
    Hello @thegreatzebadiah

    I have a couple questions:

    1. Is it required to utilize StartHostAll and StartClientAll in order for Direct Connect to work? The reason I ask is I use CreateMatch and JoinMatch in a menu scene. Once successful creation/join of the match, I move to the gameplay scene that contains the NetworkManager and call the appropriate StartHost or StartClient methods.

    2. It is understood that this plugin does not support Mobile platform. Does using this plugin preclude the ability to do PC and Mobile cross platform with Unet? For example, if a PC version utilizes a NetworkManager that inherits from NatTraversal.NetworkManager would it still be able to network with a Mobile version with a NetworkManager that inherits from UnityEngine.Networking.NetworkManager?
     
  2. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I did make some changes that could effect this in the latest versions. What version of the plugin are you using? You can find it in the README.

    If you're on 1.60 I would recommend updating to 1.61. If you're already on 1.61 then I probably messed something up. If you're on something less than 1.60 then I don't really know and I'll probably need more info.
     
  3. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I used to support something like this but it was removed because it complicated things and no one seemed to be using it. My recommendation is to not do it your way.. joining the match takes time and in many cases won't be necessary in order to establish a connection so doing it first is kind of wasteful. I would try and put my old ugly hack back in, but it would still only do half of what you want and it was real ugly. The short answer is: Yes, you do need to use StartHostAll and StartClientAll. You should not use CreateMatch and JoinMatch directly.

    Unfortunately this will not work out of the box. The NAT Traversal side running on PC will expect a message from the client that unet does not send so it won't allow the client to become ready. That's at least one issue I just noticed with a quick glance through the code. I think the ideal solution would be to actually use NAT Traversal on the mobile end as well but don't include the punchthrough bits, because those parts aren't compatible with mobile. I believe that just means making sure the import settings for all of the raknet libraries are set to exclude them from mobile builds. And of course make sure "Connect Punchthrough" is unchecked when building for mobile.
     
  4. Minamu

    Minamu

    Joined:
    Apr 28, 2014
    Posts:
    5
    Thanks for the response. We were at 1.59 but I updated to 1.61 to no avail. "RegisterHandlerClient" was missing all of a sudden, but I replaced it with "NetworkServer.RegisterHandler" instead and at least the game starts, but the audio thing is still there. Is there any difference between joining a new scene from a lobby, and leaving said scene to return to the lobby? I assume a lot of game lobby info has to be dumped on the return. Otherwise it's probably our own code playing tricks on us.
     
  5. Barkers-Crest

    Barkers-Crest

    Joined:
    Jun 19, 2013
    Posts:
    159
    The original reason for setting it up this way is due to constraints imposed by certain platforms. Platforms that usually have their own matchmaking and networking and are very specific on how they work with Unet. In addition to that, to a certain degree, I really like not pulling people out of the menu system and into the gameplay scene until the match is joined. Specifically, for the cases where the match is no longer available or full.

    With all that said, I do see your point of view. I'll spend a little time thinking about this and see if I can make it work as is.

    Okay thanks.
     
  6. auroxi

    auroxi

    Joined:
    Dec 31, 2012
    Posts:
    85
    Are there any examples on how to use this asset with other networking solutions? I can only see information relating to UNET.
     
  7. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @auroxi There is an example included with the plugin "ExampleNATHelperOnly" that demonstrates using the plugin at a lower level to perform punch through and port forwarding independent of any networking system. Both operations are essentially fiddling with the router and making holes, so in theory it should work with anything.

    Most of the UNET specific code is just connection juggling so that direct, punch through, and relay connections can all be attempted simultaneously.

    There are no examples of using NAT Traversal with other networking systems though. You can try searching this forum post for your networking solution of choice and you may find some helpful info from other users. For example I know Forge has been mentioned a couple of times.
     
  8. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I just finished some basic playmaker support. Hit me up at the support email (contact@noblewhale.com) and let me know what version of the editor you are using and I can send you something to test.

    Cheers.
     
  9. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I recently updated to the latest version of NAT Traversal from a much older version (about 1.5 years old). I wanted to ask a couple of questions before I release a build of my game with this new version to the public.

    First off, I see that OnMatchCreate is no longer being called. Checking earlier in the thread, I saw that this is no longer referenced from the StartHostAll command. I was mainly using this to get “myMatchInfo” when it was available. Now as a workaround, I’m just waiting until the NetworkManager’s “matchInfo” is not equal to zero before doing the things I would have normally done in OnMatchCreate, which seems to work ok. Just curious if that’s the best solution, or if it’s still possible to get OnMatchCreate to be called?

    Also: In doing some experimentation, I unchecked “Connect Directly”, but left “Connect Punchthrough” and “Connect Relay” checked. Often times (though not 100% of the time) when I would connect from the client on a different game window on the same PC, the following would output on the host:

    NATTraversal: relay connection replaced with direct connection

    It seems odd that this would occur, since I had unchecked “Connect Directly”. Immediately following this, “OnServerDisconnect” is called, despite the client appearing to connect anyways, and being able to play the game if I removed all of my OnServerDisconnect related code. I was hoping you could shed a bit of light on this? Is there some way to prevent this from happening? Or is this maybe something that can’t occur if “Connect Directly” is left checked?
     
  10. Bryan-Legend

    Bryan-Legend

    Joined:
    Sep 8, 2012
    Posts:
    80
    Thanks for the great asset. I'm using it over at https://store.steampowered.com/app/711810/Never_Split_the_Party/

    I'm getting error reports for the following 3 exceptions on Version 1.61. The first two exceptions usually happen together on the network server or client in the order shown here. They happen in about 3% of my games.

    The third exception happens in less than 1% and seems to happen only on the clients after a disconnect.

    I'd have exact line numbers with these but you don't include the source code for this asset.

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. NATTraversal.NetworkManager.replaceConnection (UnityEngine.Networking.NetworkConnection oldConn, UnityEngine.Networking.NetworkConnection newConn)
    3. NATTraversal.NetworkManager.OnMultiClientConnect (UnityEngine.Networking.NetworkConnection conn)
    4. NATTraversal.NetworkManager.OnMultiClientConnectInternal (UnityEngine.Networking.NetworkConnection conn)
    5. NATTraversal.NetworkManager.OnMultiClientConnectMsg (UnityEngine.Networking.NetworkMessage netMsg)
    6. UnityEngine.Networking.NetworkConnection.InvokeHandler (Int16 msgType, UnityEngine.Networking.NetworkReader reader, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:220)
    7. UnityEngine.Networking.NetworkConnection.InvokeHandlerNoData (Int16 msgType) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:202)
    8. UnityEngine.Networking.NetworkClient.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:736)
    9. UnityEngine.Networking.NetworkClient.UpdateClients () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:965)
    10. UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:1091)
    11.  
    12.  
    13.  
    14. Current Level = 0
    15. Current Room = Start
    16. Server = True
    17.  
    18. Ninjaleb Fighter Unknown *
    19. System Product Name (System manufacturer) DESKTOP-GFAPB9U Desktop a5394b07bee9333e2a6da74ae5d83cbd7e6121c7
    20. Windows 10  (10.0.0) 64bit, , 8139, 4x Intel(R) Core(TM) i3-3240 CPU @ 3.40GHz
    21. 1920x1080 96dpi FullScreen True, NVIDIA GeForce GTX 750, NVIDIA vmem: 984 Max Texture: 16384
    22.  
    23. Scene Roguelike, Unity Version 5.6.6f2

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. NATTraversal.NetworkManager.OnConnectionInfoConfirmationReceivedOnClient (UnityEngine.Networking.NetworkMessage msg)
    3. UnityEngine.Networking.NetworkConnection.HandleReader (UnityEngine.Networking.NetworkReader reader, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:469)
    4. UnityEngine.Networking.NetworkConnection.HandleBytes (System.Byte[] buffer, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:425)
    5. UnityEngine.Networking.NetworkConnection.TransportReceive (System.Byte[] bytes, Int32 numBytes, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:576)
    6. UnityEngine.Networking.NetworkClient.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:753)
    7. UnityEngine.Networking.NetworkClient.UpdateClients () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:965)
    8. UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:1091)
    9.  
    10.  
    11.  
    12. Current Level = 0
    13. Current Room = Start
    14. Server = True
    15.  
    16. Ninjaleb Fighter Unknown *
    17. System Product Name (System manufacturer) DESKTOP-GFAPB9U Desktop a5394b07bee9333e2a6da74ae5d83cbd7e6121c7
    18. Windows 10  (10.0.0) 64bit, , 8139, 4x Intel(R) Core(TM) i3-3240 CPU @ 3.40GHz
    19. 1920x1080 96dpi FullScreen True, NVIDIA GeForce GTX 750, NVIDIA vmem: 984 Max Texture: 16384
    20.  
    21. Scene Roguelike, Unity Version 5.6.6f2

    Code (CSharp):
    1. InvalidOperationException: Task_Dispose_NotCompleted
    2. System.Threading.Tasks.Task.Dispose (Boolean disposing)
    3. System.Threading.Tasks.Task.Dispose ()
    4. NATTraversal.NATHelper.stopPortForwarding ()
    5. NATTraversal.NATHelper.OnDestroy ()
    6.  
    7.  
    8.  
    9. Current Level = -1
    10. Server = False
    11.  
    12. OptiPlex 790 (Dell Inc.) LUISJAVIER-PC Desktop 68838504e61f1fee689002c40d998974d77ba41c
    13. Windows 7 Service Pack 1 (6.1.7601), , 3241, 4x Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz
    14. 1680x1050 96dpi FullScreen False, Intel(R) HD Graphics, Intel vmem: 746 Max Texture: 8192
    15.  
    16. Scene Roguelike, Unity Version 5.6.6f2
     
    Last edited: Jul 29, 2018
  11. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yeah, I removed the ability to pass in a custom OnMatchCreate method when calling start host. The proper way to handle this now is to override OnMatchCreate in your NetworkManager, which will be called. Just make sure to call the base method. I made this change to bring NAT Traversal more in line with how the standard NetworkManager works.

    This is just a case of confusing wording. A punchthrough connection is technically a direct connection, and I unfortunately refer to it as such in a few places. That message is output any time a relay connection is replaced so it could be punchthrough or a regular direct connect.

    Check out the docs for OnServerDisconnect for some info on the proper way to handle this. Because multiple connections are attempted simultaneously, each player can potentially have more than one connection to the server. This means that when the server sees a connection disconnect, it may or may not want to treat it as the player actually leaving. The solution as mentioned in the docs is to use checkForAnotherConnectionFromTheSameClient to check if the disconnecting connection is the final connection from that player. If there are no other connections, then you can safely treat it as an actual disconnect.
     
    Last edited: Aug 5, 2018
  12. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Lone-Coder Are you totally sure those first two exceptions occur on the host? Both those exceptions seem to be explicitly client related. If they are occurring on the host then something is definitely going wrong in a big way.

    I just put in a fix for the third exception. It will be in the next release.
     
  13. Bryan-Legend

    Bryan-Legend

    Joined:
    Sep 8, 2012
    Posts:
    80
    Yes. It looks like NetworkServer.active is true sometimes. Perhaps the game just disconnected and then a player started a server before things fully shut down. Is there a way I could check that the game is fully disconnected?
     
  14. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    In the scenario I mentioned before where Connect Directly is unchecked but the other two options are checked, I seem to be having issues getting the Punchthrough to work properly with my game code on a consistent basis in this latest version. I'm not entirely sure how much of this is out of my control, and how much of it is my code not taking what it needs to into account.

    It is possible that I'm sometimes running part of my code that I shouldn't be before the host player has finished doing all of its connection stuff.

    What is the optimal way for the host to do a check that a FINALIZED connection has been established with a client (meaning no more punchthrough attempts etc.), and retrieve this finalized NetworkConnection?

    Also - In regards to my previous post: In OnServerDisconnect should "base.OnServerDisconnect" only be called after checkForAnotherConnectionFromTheSameClient? If I call checkForAnotherConnectionFromTheSameClient after calling base.OnServerDisconnect, it always seems to return null.

    I guess in general, I'm not entirely 100% on what needs to be done to foolproof my game for punchthrough -- especially for cases where a player joins, quits, and rejoins in rapid succession, or multiple players join in rapid succession (those cases tend to causes issues where direct/relay connections do not).

    EDIT: Thought I had a solution, turns out I did not
     
    Last edited: Jul 31, 2018
  15. Sholms

    Sholms

    Joined:
    Nov 15, 2014
    Posts:
    85
    The host migration example are using 4 ccu of my multiplayer service with only 1 host and 1 client, why is that? also im not using the connect relay.
     
  16. TubooBokBok

    TubooBokBok

    Joined:
    Mar 2, 2014
    Posts:
    30
    Hello @thegreatzebadiah

    This is most likely a bug in Unet (or my implementation), but I will run it by you just in case the issue is related to your asset.

    When changing scene using ServerChangeScene(string newSceneName), if a client loads the new scene before the host, network objects that were spawned in the previous scene will be present in the newly loaded scene on clients until the server has finished loading the new scene.

    A bunch of "Spawn scene object not found for x" errors also appear.

    This does not seem to do any harm, as once the host finishes loading the new scene, all the wrongly spawned objects are destroyed.

    I am using version 1.58 of this asset.

    Any chance this is related to your asset?
     
  17. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I was just trying to replicate your issue by starting a host immediately after disconnecting as a client, but then I accidentally replicated it a completely different way just by chance!

    I get those exact two exceptions if I click the "Join" button in the example scene twice quickly (but not too quickly..). So it seems like the issue is that you are somehow trying to connect while already in the process of connecting.

    The simplest solution would be to wrap your StartClientAll call with a check for client == null like:
    Code (CSharp):
    1. if (client == null)
    2. {
    3.     StartClientAll(match);
    4. }
    That way it will never try to connect when a client has already been created.

    I'll probably work something similar into the plugin so that the check won't be necessary in the future, but that should get things working for you in the meantime.
     
  18. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I don't believe there is any good way to do this right now. I can probably find a way to do it, but I wonder how necessary it is. Ideally it shouldn't matter if the client replaces their connection all day as long as it is handled properly.

    For the most part you can start working with the first connection a client establishes without any issues. Things like message handlers and player controllers are all copied automatically when a connection is replaced.

    There is also OnConnectionReplacedServer which you can override to know when a client's connection is being replaced. The old and new connection are both passed which hopefully will allow you to handle updating anything that refers to the old connection.

    Can you elaborate a bit more on this? You could be doing something I haven't thought of or I may at least be able to help you figure out some work around based on OnConnectionReplacedServer.

    Yeah. Sorry I didn't specify that.

    I'll try and do some testing in this area and see what I can find. I honestly haven't done much testing of rapid connections so there probably are some issues.
     
  19. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I was seemingly able to fix most of the issues I mentioned through fixing some bugs in my own code. I've seen certain issues pop up on occasion if I have a user quit and return to the game very quickly, or two users quitting and joining in rapid succession, but to be honest it's not consistent enough for me to say if it's related to punchthrough or not. I'll see how things go when I release this to my user base later this week.
     
  20. MicahDuck

    MicahDuck

    Joined:
    Nov 25, 2016
    Posts:
    8
    @thegreatzebadiah I was wondering what conditions have to be met for the Unity relay servers to work with NAT Traversal. I'm trying to test that they work as a back up plan. But If I have other options("Connect Directly"/"Connect Punchthrough") unchecked but "Connect Relay" checked. It isn't connecting. I'm assuming that I don't have something set up correctly. I have unity multiplayer enabled.

    Any help would be great Thanks! Also what is your guys discord?
     
  21. MicahDuck

    MicahDuck

    Joined:
    Nov 25, 2016
    Posts:
    8
    @thegreatzebadiah Also if someone was having issues would opening the ports 61111 20203 on their router help? are there any other ports and what type?
     
  22. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @MicahDuck

    Usually if relay connections aren't working it's because I firewall is blocking something. Otherwise relay connections should always work.

    You shouldn't have to open any ports on the router for host or clients. The only thing you would need to open ports for is the Facilitator and Match Up Server if you're hosting your own somewhere. Players should never have to fiddle with any router settings themselves, that's the plugin's job.
     
  23. MicahDuck

    MicahDuck

    Joined:
    Nov 25, 2016
    Posts:
    8
  24. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @MicahDuck sorry we don't have a discord ourselves, but I do hang out in the Unity Developer Hub discord occasionally. https://discord.gg/bQJP4q with the name Whale Whale Whale #8113
     
    Last edited: Aug 9, 2018
  25. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Even without relay connection you should expect to see at least two CCU per host if you have matchmaking enabled. 1 CCU for the host itself and 1 CCU so that the match isn't full. Your seeing 4 CCU because there are two hosts. The 2 CCU from the first host should get cleaned up after migration but it looks like they are not. I'll look into fixing that and maybe see if I can make it optional to create a new match when migrating hosts.
     
  26. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Just a heads up, I just submitted a new version of NAT Traversal, so for anyone running into the editor script issue preventing them from building, a fix will be out soon! If you need it immediately email me with your invoice number and your Unity editor version and I can send you a build.
     
    hickna likes this.
  27. TubooBokBok

    TubooBokBok

    Joined:
    Mar 2, 2014
    Posts:
    30
    Hello @thegreatzebadiah

    When attempting to connect to a host on my lan the connection fails and I receive the following message (on the host computer):

    "NATHelper: Unexpected raknet message received: ID_NAT_PUNCHTHROUGH_FAILED"

    Perhaps the host being connected to a wireless extender has something to do with the error?

    Do you know what might be causing this connection to fail?

    Thank you.
     
  28. hickna

    hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    I just purchased the package and tried to build the Example scene without success.
    I already have uploaded the Facilitator in my server and is working fine (at least seems to be working when creating the host). So, my current issue is that I can't even test a client because this :

    Assets/Plugins/NAT Traversal for UNET/AddScriptingDefines.cs(12,40): error CS0246: The type or namespace name `Editor' could not be found. Are you missing an assembly reference?

    upload_2018-9-2_15-24-3.png

    Please @thegreatzebadiah I need a quickly support. Thanks!

    PS: I can't find your email for support by the way...
     
    Last edited: Sep 2, 2018
  29. hickna

    hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    Issue "Editor could not be found issue" fixed here.
    Thanks a lot @thegreatzebadiah !

    Now I'm having trouble to connect a client. When I try to connect a client seem that the NATHelper is not considering the port passed through StartClientAll()

    string[] hostData = connGetHost.text.Split(',');
    hostIP = hostData[0];
    hostPort = int.Parse(hostData[1]);
    hostRakNetGUID = ulong.Parse(hostData[2]);
    //-----------------------------
    StartClientAll(hostIP, hostIP, 7777, hostRakNetGUID);
    //-----------------------------



    The host is using the port 7777 and I'm trying to connect in this port.. But the console shows that client is trying to connect is some "random" port... Each time a different port:
    upload_2018-9-2_20-59-1.png
     

    Attached Files:

  30. deliinteractive

    deliinteractive

    Joined:
    Oct 8, 2014
    Posts:
    25
    Hi @ricna-net ,
    My understanding is the port you are specifying is for direct connections. A direct connection is almost certainly being attempted on port 7777 - we use this successfully in We Need to Go Deeper. It's the punchthrough connection (and potentially the UPNP-based connection) whose port is randomly selected from the unassigned range.
     
  31. hickna

    hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    While using StartClient() by default in 7777, without this plugin, the connection was successfully. But i dont want to ask to anyone to set up the router manually, so I purchased this plugin..
    Unfortunately I'm still not understanding which port I need to specify in StartClientAll() :(
     
  32. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @ricna-net hopefully I've cleared things up in my email, but for anyone reading along here, @deliinteractive has it right. You use the host's networkPort in the call to StartClientAll(). This is the port used for direct connection. The GUID from the host's NATHelper is what is used for the punchthrough connection. You don't need to know the port for punchthrough, which makes sense because the port is not actually determined until the host and client go through the punchthrough process to negotiate it, which happens after the call to StartClientAll().
     
    Last edited: Sep 3, 2018
    hickna likes this.
  33. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Sure sounds like your guess is right. I'm assuming something about the wireless extender throws off the punchthrough process. I don't think there's anything that can be done about it other than falling back to relays.

    If you're willing to help me out testing some new stuff though I might have a solution for you in the long term. I've been working on a new product that includes relays and a completely different type of punchthrough. It may or may not work in this situation but I would definitely be curious to find out, as that would be some evidence that it is more effective than the punchthrough in NAT Traversal.

    Hit me up at the support email if you're interested.

    ---

    By the way for everyone who can't find the support email it is support@noblewhale.com

    For some reason Unity makes it super hard to find but it's on the Noble Whale Studios publisher page which you can get to from any of our assets.
     
    Last edited: Mar 16, 2019
  34. hickna

    hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    Thanks a lot @thegreatzebadiah for your support by email. Unfortunately i'm still having troubles with the Timeout issue.

    upload_2018-9-3_15-17-19.png

    Wondering if the second argument should be the local IP ^^^^


    Here the client issue... Host accpet the client, client see the host, Facilitator seems ok, but then.. "Client disconnected" and the Timeout error later.
    upload_2018-9-3_15-23-28.png

    Help please!
     
  35. hickna

    hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    I'm feeling so stupid. Now I see that I was not getting the correct param to use as hostInternalIP
    Now is working in LAN and also works when my friend create the host. I can connect as client, but when I create the room he can't connect.. Seems some problema with my router :/

    upload_2018-9-3_17-19-33.png
     
  36. UGTools

    UGTools

    Joined:
    Oct 10, 2012
    Posts:
    738
    Is there any news regarding Android support? I recently bought the plugin and it works great but now I need it for a mobile app (Oculus Go which uses Android) and I can't use the NAT punchthrough for the wifi :(
     
  37. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @UGTools No news I'm afraid. Mobile support is not likely to be coming to NAT Traversal.
     
  38. TubooBokBok

    TubooBokBok

    Joined:
    Mar 2, 2014
    Posts:
    30
  39. Zebadiah

    Zebadiah

    Joined:
    Apr 6, 2014
    Posts:
    67
    @TubooBokBok It may be possible but I'm about to release a competing relay solution so I'm probably not going to put any effort into making that happen. Sorry to be so blunt, but I am running a business here!

    If you manage to get it working yourself though feel free to post about it here. I'm not opposed to integrating with everything under the sun, but I can't really justify putting effort into it myself when I've got so much on my plate already.
     
    Last edited: Sep 15, 2018
  40. TubooBokBok

    TubooBokBok

    Joined:
    Mar 2, 2014
    Posts:
    30
    Thank you for the response. I completely understand.

    I look forward to the release of the new asset you are working on.
     
  41. hickna

    hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    I'm having troubles to connect using the punchthrough. If I check the "Connect Directly" option then works running 2 instances in the same computer. I'm curious about the message that seems to say that was connected via punch-through, but its not.. :/

    upload_2018-9-18_2-7-57.png

    PS: I got the same result trying to connect in 3 different hosts in an external network. I just got this working in 2 cases (hosts) until now, using exactly the same build. I'm frustrated because I will not want to publish a game where in the most of situations the host will not be able to receive connections.
    Note that we are 5 in different places in the world testing it. Just 2 guys of the team are able to be a host then we all can test connecting N clients. Why the others can't be a host? We don't know.
    So I hope that whits work in 2 instances in my computer as works using a manual portforwarding, so disabling the "Connect Directly" i'm looking for some solution to see the punch-though working.


    Thanks.
     
    Last edited: Sep 18, 2018
  42. hickna

    hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    Hi @thegreatzebadiah ...
    We are testing the game right now and we notice that client seems connected (with traffic) but the Scene Online never loads... If the host closes the room then all clients receives the timeout.
     
  43. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @ricna-net I responded to you via email but I'll post some of the info here as well for anyone else with similar issues

    If you've got an "Online Scene" and "Offline Scene" set on the NetworkManager then the client should receive a message from the server as soon as they connect telling them to change scenes. So when the client connects to the server instead of calling OnClientConnect() immediately it waits until after the scene finishes loading. Typically OnClientConnect() is where players are spawned so you don't want it to be called until the online scene has finished loading.

    I'm not sure what could cause the scene to never load. If, as you say, the connection has been made and traffic can be sent then the Scene message from the sever should have been received and the client should change scenes. On the client if you set the log level to debug you should see "NetworkManager:OnClientSceneInternal" in the log and then "ClientChangeScene newSceneName:". If you don't see either then the client is not receiving the message at all. If you see one but not the other then the message is being received but for some reason the scene never starts loading. If you see both but the scene isn't loading then something has to be going wrong while loading the scene.
     
    hickna likes this.
  44. tststs

    tststs

    Joined:
    Jul 16, 2016
    Posts:
    11
    Hey,

    So i'm starting a server via:

    Code (CSharp):
    1. StartServerAll("Hello World", customConfig ? (uint)(maxConnections + 1) : matchSize);
    Connecting with a client is working and the player prefab is spawned. The problem is that when the client is calling a Command this warning pops up on the server:

    NATTraversal: Instance not found when handling Command message [netId=1]
    UnityEngine.Debug:LogWarning(Object)
    NATTraversal.NetworkManager:OnCommandMessage(NetworkMessage) (at E:/_Noble Whale/NAT Traversal/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:1051)
    UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

    This is not happening if calling the StartHostAll method with the host and then connecting with another client. Is there anything i'm missing?

    Thanks!
     
  45. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @tststs It's a bug! Contact me at support@noblewhale.com with your invoice number and I'll send you a new build. Or if you're patient it will show up on the asset store in a week or so.
     
  46. tststs

    tststs

    Joined:
    Jul 16, 2016
    Posts:
    11
  47. l3fty

    l3fty

    Joined:
    Mar 23, 2013
    Posts:
    87
    Hi @thegreatzebadiah is it possible to use your nat traversal without falling back onto the relay servers? In such events I'd rather a connection just failed to establish than to rely on third party servers etc. In my setup I'm not using the relay or the matchmaker.
    Thanks!
     
  48. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yep, it's as simple as unchecking the "Connect Relay" checkbox.
     
    l3fty likes this.
  49. Romenics

    Romenics

    Joined:
    Jan 10, 2015
    Posts:
    4
    Hello!
    In documentation for your NAT Traversal I read:

    "Adds NAT punch-through and automatic port-forwarding to any peer-to-peer networking system"

    Sounds like exactly what we need!
    However I didn't found an instruction of how to do it.
    We are using TNet
    https://assetstore.unity.com/packages/tools/network/networking-and-serialization-tools-tnet-3-56798

    Can you please provide some information about how I can use NAT Traversal in order to implement NAT punch-through feature for TNet?

    By the way, if you are not a familiar with TNet, I recommend you to take a look on it. This is a hidden gem among network solutions which have a few unique features, never saw such feature in any network system and seems like this is how future network solution should looks like. But it lacks NAT punch feature. So maybe you will decide to add a native support for TNet? It is much more perspective in comparison with UNET, especially due a fact that UNET will be dropped by Unity very soon (again).
     
    Artaani likes this.
  50. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Romenics Take a look at the ExampleNATHelperOnly scene, it's got some examples for how to use the NAT Helper directly to perform punchthrough and port-forwarding. Once the punchthrough is performed you should just need to make sure you are hosting on the correct port on the host and connecting from / to the correct ports on the client to connect over the punched hole.

    To quote the README from the NAT Helper example:
     
    Romenics and Artaani like this.