Search Unity

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

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

  1. siliwangi

    siliwangi

    Joined:
    Sep 25, 2009
    Posts:
    303
    try :
    Code (csharp):
    1.  
    2. apt get install procinfo
    3. socklist
    4.  
    It will show on which port the Facilitator being listened into, and enter your ip and port number into http://www.canyouseeme.org/ site. If it's open then the problem could be reside on Facilitator codes or your own codes.

    Incase the port is seen as closed by that website, try this :
    Code (csharp):
    1.  
    2. ufw status verbose
    3. ufw allow insert_port_number_here/tcp
    4. ufw allow insert_port_number_here/udp
    5. for example :
    6. ufw allow 32000/tcp
    7. ufw allow 32000/udp
    8.  
    9. and verify it if it's been inserted and opened by :
    10. ufw status verbose
    11.  
    Retry with that website.
     
  2. spinaljack

    spinaljack

    Joined:
    Mar 18, 2010
    Posts:
    992
    I contacted 1and1 customer support and they told me how to open those firewall ports and add ICMP protocol and everything is good now. :)
     
  3. Ranger-Burke

    Ranger-Burke

    Joined:
    Oct 7, 2015
    Posts:
    11
    OnMatchJoined.. has anyone seen this called correctly using this?
     
  4. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    88

    My facilitator is fine. I am having troubles with finding the NAT device. I get the "NAT device not found" error. Any idea what might fix it?
     
  5. Ranger-Burke

    Ranger-Burke

    Joined:
    Oct 7, 2015
    Posts:
    11
    I get that "error" too, but I'm ignoring

    Before I get that, I get from the Nat Helper OnDoneConnectingToFacilitator >>

    NATHelper: Connected to Facilitator: 112139653502771XXXX

    After that, I'm able to create a match and have another player find it by punching a hole.

    (I wait for NATHelper.singleton.isConnectedToFacilitator in my quick play networking test)

    Don't know if that helps, but more data to work with...
     
    akuno likes this.
  6. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    244
    has anyone had good luck with host migration? i'm just testing the plugin's Example scene in an empty project to isolate problems.

    i'm still on Unity 5.3.5f1 and i've turned off "Connect Relay" on the ExampleNetworkManager.

    here's some show stopping problem scenarios i've identified so far -

    - Scenario 1 -
    1. fire up 2 instances of the app on one machine. instance A hosts, instance B joins.
    2. instance A presses disconnect.
    3. instance B is now prompted with the migration UI. use this to become the new host.
    4. instance A can now reconnect to the new host (instance B). this works great!
    5. instance B (new host) now presses disconnect.
    6. instance A (now a client) never sees the migration UI pop up.

    it's worth noting that with this scenario, that ONLY after the first disconnect does a client see this message - i believe this is probably what kicks off the migration UI process? (& presumably if it never catches this message the second time around, the migration UI would never trigger)

    NetworkMigrationManager client OnDisconnectedFromHost
    UnityEngine.Networking.NetworkMigrationManager:LostHostOnClient(NetworkConnection)
    NATTraversal.MigrationManager:LostHostOnClient(NetworkConnection) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/MigrationManager.cs:186)
    NATTraversal.NetworkManager:OnMultiClientDisconnect(NetworkConnection) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:1296)
    NATTraversal.NetworkManager:OnMultiClientDisconnectMsg(NetworkMessage) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:1260)
    UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()



    - Scenario 2 -
    got a null error on 3/3 attempts on this line in the Example Migration Manager-

    client.ReconnectToNewHost(newHostAddress, networkManager.networkPort);

    here's the callstack -

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.Networking.NetworkClient.ReconnectToNewHost (System.String serverIp, Int32 serverPort)
    ExampleMigrationManager.OnGUIClient () (at Assets/NAT Traversal Example/ExampleMigrationManager.cs:118)
    ExampleMigrationManager.OnGUI () (at Assets/NAT Traversal Example/ExampleMigrationManager.cs:26)


    repro:
    3 instances of the app running on one machine -
    1. A (standalone) hosts
    2. B (standalone) joins
    3. C (unity editor) joins.
    4. A disconnects.
    5. B and C should see the host migration UI pop up. (i've seen this step mess up occasionally where only one client will get the migration UI btw but that's a separate issue i need to further isolate)
    6. B should become the new host.
    7. C (the unity editor player) should attempt to reconnect to the new host. he sees the null ref exception.

    is this important? i notice that C gets this log message right before the null ref -
    ClientScene::SetReconnectId: 2

    but...if i'm understanding the host migration stuff correctly, C's connection id is 2. i think he should be trying to connect to B...whose connection id is 1...
     
  7. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    88
    Thanks, I ignored the message aswell and can connect to the facilitator. But my client do not connect to a hosted match when I click Join.

    Do you mind sharing your connect method? What steps do you make to connect?
     
  8. Ranger-Burke

    Ranger-Burke

    Joined:
    Oct 7, 2015
    Posts:
    11
    Basicallly, something like --

    Code (csharp):
    1.  
    2. JoinFirst() {
    3.    ...
    4.    matchMaker.ListMatches( 0,20, "", true, 0, 0, OnMatchList);
    5. }
    6. public override void OnMatchList(bool success, string extendedInfo, List<MatchInfoSnapshot> matchList) {
    7.         base.OnMatchList(success, extendedInfo, matchList);
    8.         //auto-join the first for first test
    9.         if ( success && matchList != null && matchList.Count > 0 ) {
    10.             MatchInfoSnapshot match = null;
    11.             if (natHelper.guid != 0) {
    12.                 foreach (MatchInfoSnapshot m in matchList)  {
    13.                     string[] parts = m.name.Split(':');
    14.                     ulong hostGUID;
    15.                     ulong.TryParse(parts[parts.Length - 1], out hostGUID);
    16.                     if (hostGUID == natHelper.guid)
    17.                     {
    18.                         Debug.Log("Not joining old match");
    19.                     }
    20.                     else
    21.                     {
    22.                         match = m;
    23.                         break;
    24.                     }
    25.                 }
    26.             }
    27.             else {
    28.                 match = matchList[0];
    29.             }
    30.             if ( match == null ) {
    31.                 Debug.LogError( "couldn't successfully pull match from list?!?");
    32.                 return;
    33.             }
    34.             matchID = match.networkId;
    35.             StartClientAll(match, OnMatchJoined);
    36.        }
    37.        else {
    38.               //deal with failures
    39.         }
    40.  
    41.  
     
    akuno likes this.
  9. voltage

    voltage

    Joined:
    Nov 11, 2011
    Posts:
    515
    Does Nat Traversal support 5.4.2f2 yet? Probably shouldn't have upgraded..

    MatchDesc and ListMatchResponse doesn't work anymore.
     
    Last edited: Oct 22, 2016
  10. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Sticking with 5.4.1 for now (Only things I've seen introduced in Unity 5.4.2 so far are more crashes :p).

    We've found a couple of issues with the plugin while testing, most of them are not easily reproducible, but I have the log for one of them.

    This crash happened while we were hosting a game behind a router on our office, (we left the game running for around 15 minutes), and we tried to connect from another computer on our home behind a router as well.

    Code (csharp):
    1. NATHelper: Hole is punched on port: 49795
    2. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    3. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    4. UnityEngine.Logger:Log(LogType, Object)
    5. UnityEngine.Debug:Log(Object)
    6. NATTraversal.NATHelper:listenForPunchthrough(Packet)
    7. NATTraversal.<messageLoop>d__44:MoveNext()
    8. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    9.  
    10. (Filename: C:/buildslave/unity/build/Runtime/Export/Coroutines.cs Line: 17)
    11.  
    12. NATHelper: Connected to Facilitator: 238690797106495192
    13. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    14. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    15. UnityEngine.Logger:Log(LogType, Object)
    16. UnityEngine.Debug:Log(Object)
    17. NATTraversal.NATHelper:OnDoneConnectingToFacilitatorInternal(UInt64, Packet)
    18. NATTraversal.<messageLoop>d__44:MoveNext()
    19. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    20.  
    21. (Filename: C:/buildslave/unity/build/Runtime/Export/Coroutines.cs Line: 17)
    22.  
    23. NATHelper: Hole is punched on port: 52771
    24. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    25. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    26. UnityEngine.Logger:Log(LogType, Object)
    27. UnityEngine.Debug:Log(Object)
    28. NATTraversal.NATHelper:listenForPunchthrough(Packet)
    29. NATTraversal.<messageLoop>d__44:MoveNext()
    30. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    31.  
    32. (Filename: C:/buildslave/unity/build/Runtime/Export/Coroutines.cs Line: 17)
    33.  
    34. Crash!!!
    35. <plenty of dlls here>
    36.  
    37. ========== OUTPUTING STACK TRACE ==================
    38.  
    39. 0x000000005860CA2E (RakNet) CSharp_RakNetGUID_g_get
    40. 0x000000002D5BD1CC (Mono JIT Code) (wrapper managed-to-native) RakNet.RakNetPINVOKE:RakNetGUID_g_get (System.Runtime.InteropServices.HandleRef)
    41. 0x000000002D5BD008 (Mono JIT Code) RakNet.RakNetGUID:get_g ()
    42. 0x0000000040733E8C (Mono JIT Code) NATTraversal.NATHelper:listenForPunchthrough (RakNet.Packet)
    43. 0x000000002D573463 (Mono JIT Code) NATTraversal.NATHelper/<messageLoop>d__44:MoveNext ()
    44. 0x000000002491C128 (Mono JIT Code) [C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17] UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)
    45. 0x000000002491C29B (Mono JIT Code) (wrapper runtime-invoke) <Module>:runtime_invoke_void_object_intptr (object,intptr,intptr,intptr)
    46. 0x000007FEE770503F (mono) [c:\buildslave\mono\build\mono\mini\mini.c:4937] mono_jit_runtime_invoke
    47. 0x000007FEE7658385 (mono) [c:\buildslave\mono\build\mono\metadata\object.c:2623] mono_runtime_invoke
    48. 0x00000001403632BF (Unity) scripting_method_invoke
    49. 0x00000001404CA80F (Unity) ScriptingInvocation::Invoke
    50. 0x000000014033D12E (Unity) Coroutine::InvokeMoveNext
    51. 0x000000014033D5E5 (Unity) Coroutine::Run
    52. 0x00000001401338E5 (Unity) DelayedCallManager::Update
    53. 0x0000000140468AD3 (Unity) PlayerLoop
    54. 0x0000000140BD9E95 (Unity) Application::UpdateScene
    55. 0x0000000140BDB419 (Unity) Application::UpdateSceneIfNeeded
    56. 0x0000000140BE32B4 (Unity) Application::TickTimer
    57. 0x0000000140E4768E (Unity) FindMonoBinaryToUse
    58. 0x0000000140E48CC1 (Unity) WinMain
    59. 0x00000001415CB660 (Unity) strnlen
    60. 0x00000000772F5A4D (kernel32) BaseThreadInitThunk
    61.  
    62. ========== END OF STACKTRACE ===========
    63.  
    64.  
    We're also experiencing problems when a connection can't be properly established (sometimes it ignores timeouts and doesn't ever throw an error, so we have to stop the attempt by hand).

    Even with this, it works most of the time, so we're releasing our game tomorrow with the plugin, let's hope everything works out and it doesn't explode in our face :)

    http://store.steampowered.com/app/503350
     
  11. Querke

    Querke

    Joined:
    Feb 21, 2013
    Posts:
    54
    Hello!

    Just purchased your asset, as it looks like a really good solution!

    However, I have only done pure gameplay coding before, and don't know anything about networking.

    Is there any guide, or could you just help me in the right direction how to set it up like this (1v1 pvp game):
    In the lobby screen, there is a big PLAY button.
    When pressing it (using unity's UI button, calling a method inside network manager), you will start searching for other players.
    When another player presses the PLAY button on his client, he will also start searching.
    And it should automatically find the other player and start the match.
     
  12. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Instinct you are more-or-less describing the ExampleScene and ExampleNetworkManager that are included with the plugin. Give them a look, they should point you in the right direction.
     
  13. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    That's awesome to hear man. Sorry you're still experiencing some issues with the plugin. I think I've got three separate issues logged for you right now that I'm about to start looking into so hopefully some of it will be resolved soon. That latest one though sounds like one of those mysterious things that will be impossible to reproduce and may never happen again..
     
  14. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I believe 5.4.2f2 should work, you probably just need to update the plugin via the asset store. Also sometimes updating the plugin doesn't work for some reason so make sure to check the README that comes with the plugin to make sure you've got the right version. It should say "Unity Version: 5.4.*" somewhere near the top.
     
  15. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Sorry but mobile is not currently supported and it will likely be a while before I have time to even start looking into it. I at least wouldn't expect anything before 2017.
     
  16. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I was just looking at some of the code you posted here: http://pastebin.com/6Mut5nwy and I think I see some weirdness. In the Awake() method there you're calling the natHelper's Awake method, but won't that be done automatically? By calling it there I think it will end up being called twice which could definitely have some strange effects. I'm not sure if it actually has anything to do with the crashes you're experiencing but it might be worth looking in to.
     
  17. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @robochase @yuchun1108
    I believe I just fixed both of these issues. I'm working on packaging up the next release now so it should be on the store within a week.

    I think I have some ideas about this one as well. Maybe something to do with trying to migrate host while punchthrough is still happening.
     
  18. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Well, the game got released and most people is able to play without issues so that's great :)

    However, that's not always the case, some people have experienced crashes that I'm guessing are the same as the one I posted earlier (don't have the log file so I can't be sure, it might be an unrelated engine crash), and some people has been unable to connect to specific clients, but it could be a plain timeout issue.
     
    thegreatzebadiah likes this.
  19. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    There were a couple of problems in the plugin that were preventing this from working. I think I've got it all resolved now but it's not as clean I would have liked. I had to add a new method to the NetworkManager that you'll have to use to disconnect connections. The issue is with punch-through connections; they require a custom Disconnect method, and of course NetworkConnection.Disconnect is not virtual so I can't just override it.

    The new method is called DisconnectConnection and it will be in the build that I'm finishing up hopefully by tonight.
     
    Last edited: Oct 31, 2016
  20. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    That's great!

    I'd like to point out that our biggest issue currently is the crash that sometimes happens (log file available on #260)
     
  21. KaZe_

    KaZe_

    Joined:
    May 13, 2015
    Posts:
    12
    Hello,

    I've been trying to run the example you gave on Unity 5.4.1 and I receive the following error all the time when pressing host:

    I've already set up the Matchmaking and on the client the list always return empty. Is there anything missing here or is it a bug?
     
  22. KaZe_

    KaZe_

    Joined:
    May 13, 2015
    Posts:
    12
    Ok, from my last post I've found a solution here. There was an update between the time the plugin was bought and I started using it here. The update fixed the problem. I'll let the post there if anyone has the same problem.

    But now I have another question, is the Punch through only applied then the StartHostAll is called?

    Let me get some example here. I'd like only to connect 2 players that are inside routers. Don't want to use match making or open any rooms
     
  23. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @WaaghMan I think I just found the source of the crash. I can't be 100% sure since I've never been able to replicate it but it looks promising. I should have it packaged and re-submitted to the store today.
     
  24. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @KaZe_ Yeah, punch-through only happens when StartHostAll is called, or you can use it manually via the NATHelper but it's a little more complicated.

    If you mean they are both behind the same router then you don't need my plugin at all. UNet has some built in game discovery stuff that will find games on the local network so you can join them. If you mean two players behind separate routers then you've come to the right place, but you still need some sort of matchmaking.

    Without some kind of matchmaking there is no way for clients to get the host's connection info so they can't even begin to try to connect or punch-through or anything. If you want to turn UNet matchmaking off so that you don't use any CCU then you will have to replace it with some other matchmaking system (steam lobbies are a popular choice). There is no matchmaking provided by the plugin.
     
    KaZe_ likes this.
  25. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Alrighty, the latest update has been submitted. It should be on the asset store in the next couple of days (a week at most). It's got a ton of cool new stuff like experimental ipv6 support and less crashing!
     
    KaZe_ likes this.
  26. KaZe_

    KaZe_

    Joined:
    May 13, 2015
    Posts:
    12
    Sorry, I probably didn't made myself clear. 2 different machines, each one behind a different router. The game won't have a Matchmaking. One will connect direct to a friend to play ( probably using steam to select the friend ).

    One more question: We use the LLAPI to sync some stufff inside the game. Is it possible to use the punch through on the LLAPI?
     
  27. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Great news about the update! Any chance we can get it a bit earlier (my email is waaghman@gmail.com )? The sooner the better, but no worries if you can't/you don't want to :)

    KaZe, you should be able to use the plugin for that.

    On the host, just call StartHostAll, wait until you get a guid for the punchthrough (it doesn't always get one, so be sure to handle that case), and then fill a Steam lobby with the required data (internal IP, external IP, punchthrough guid).

    On the client, join the steam lobby, get the IPs and the guid, and call StartClientAll. That should be enough.
     
  28. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    So i guess matchmaking is also done by the facilitator and not by UNET, right?
    If yes, is there a way to provide properties to the match info? As you know, there's no way to update the "name" of the UNET match, so there's no way to know for instance which level is being played in the match.
     
  29. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    I think the facilitator is only there to allow NAT punchthrough (you connect to it to open a hole which is then used to connect to the server / be connected by others). It doesn't relay connections or give information about other peers connected to the facilitator. But I could be wrong.

    Matchmaking would still be done by UNET or whichever matchmaking system you want to use (even if it's a simple "Enter Server's IP address" input field).
     
    thegreatzebadiah likes this.
  30. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    While waiting for the update to come out, I have a question:

    We want to show some kind of information to players when they won't be able to connect or receive connections. The usual "NAT: Open" or "NAT: Limited" should be enough.

    I'm not sure if there's a way to do that with the current API. I guess that if the host managed to connect to the Facilitator, that means anyone can connect to it, but I'm not entirely sure this is true, so some kind on guidance on this would be appreciated.
     
  31. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @WaaghMan

    There is nothing like that built into the plugin at the moment but it may be something I can add in the future.

    I don't think this is the case. Pretty much any host should be able to connect to the Facilitator since it is an outgoing connection initiated by the host, but that doesn't necessarily mean they will be able to accept an incoming punch-through connection.

    @iddqd
    Pretty much what WaaghMan said, matchmaking is not handled by the plugin, you can use whatever system you want including unet. And yeah, it's terrible that with unet matchmaking there is no way to update the match name or other metadata after creating the match, it's a constant thorn in my side.

    @KaZe_
    Exactly as WaaghMan said above.

    P.S. @WaaghMan I think you're giving out better support than me at this point. Thanks man. I'm emailing you the latest build right now. You may want to remove your email address from the post now that I've got it so some bot doesn't scrape it and start spamming you.
     
  32. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Version 1.45 released
    • Added IPv6 support (experimental)
    • Fixed some issues with host migration.
    • Improved error handling when joining a match fails.
    • Removed "GrabblesGame.com" as default port mapping description.
    • Fixed a potential crash when exiting a build while a nat device is still being found.
    • Added a call to OnHolePunchedClient() so that more failures can be caught and handled.
    • Fixed some issues with disconnecting punch-through connections.
    • Fixed occasional crash when receiving punch-through.
    • Updated Documentation.
    Thanks everyone who has continued to help me improve the plugin. There were a couple of features that didn't make it into this release that will hopefully be in the next one including NetworkLobbyManager support and nat type detection.

    If you haven't rated / reviewed the plugin on the asset store, I would really appreciate it. It only takes a moment and it would make my day :)

    [edit] Thanks whoever just made my day :)
     
    Last edited: Nov 10, 2016
  33. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    Hi i just got your plugin.

    Is it possible to use UNET Relay, but a custom matchmaking?
    I guess this is a general question if UNET supports this ;-)
     
  34. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Hi, two issues found on latest version that we got from our error analytics, the first one should be easy to fix, the second one I'm not so sure:

    ArgumentNullException: Argument cannot be null. Parameter name: hostNameOrAddress System.Net.Dns.GetHostEntry (System.String hostNameOrAddress) NATTraversal.NetworkManager.getIPAddress (System.String hostName, IPTYPE ipType, ADDRESSFAM Addfam) NATTraversal.NetworkManager.StartHostAll (System.String matchName, UInt32 maxPlayers, Boolean advertise, System.String password, Int32 eloScore, Int32 requestDomain, UnityEngine.Networking.Match.DataResponseDelegate`1 callback)


    NullReferenceException: Object reference not set to an instance of an object NATTraversal.NetworkManager.createClient () NATTraversal.NetworkManager.StartClientAll (System.String hostExternalIP, System.String hostInternalIP, UInt64 hostGUID, NetworkID matchID, System.String hostExternalIPv6, System.String hostInternalIPv6, UnityEngine.Networking.Match.DataResponseDelegate`1 joinMatchCallback, System.String matchPassword, Int32 eloScore, Int32 requestDomain, Boolean matchAlreadyJoined) QuickJoinScript+<JoinServer>c__Iterator65.MoveNext () UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) GoogleAnalyticsV4:HandleException(String, String, LogType) UnityEngine.Application:CallLogCallback(String, String, LogType, Boolean)

    The first one is rather frequent (~40 events in the past 2 hours), the second one a bit less but frequent enough (~9 events)
     
  35. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @iddqd Yep, you can use any kind of matchmaking you want and still use UNet's relays. After calling StartHostAll() you can get the unet match id in OnMatchCreate(). This is the id that clients will use to connect via relay. The clients pass the match id in to StartClientAll() along with the other connection info to connect.

    @WaaghMan Good stuff. First one seems to be related to the new ipv6 support. The second one I'm really not sure about.
     
    iddqd likes this.
  36. qingmeng

    qingmeng

    Joined:
    Oct 29, 2016
    Posts:
    5
    @thegreatzebadiah Hi, I have purchased your asset. I think it's awesome! I did encounter some issues however.

    When I try to run the facilitator on the intended production server (a very small but supposedly high performing vps), it doesn't bind to the correct ip address. It binds to 127.0.0.2 on venet0, instead of the real ip on venet0:0. Is there some parameter I can pass to the facilitator to bind to another ip or a specific device? Or perhaps it can bind to 0.0.0.0?

    I don't fully understand how hole punching works. I read the host opens a socket to send something out, and doesn't close it therefore getting a opened port on the public router. Once this port is opened, is the client able to connect to it directly? As long as it knows the public IP of the host? Or does the client still need the facilitator to do some magic trick?

    Would much appreciate your answers!
     
  37. durundal

    durundal

    Joined:
    Mar 28, 2013
    Posts:
    2
    So, should we expect host migration to work over the net / relay servers and not just on local direct connections?
     
    iddqd likes this.
  38. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,697
    Hi,
    I know virutally nothing when it comes to network servers, backend stuff. I am setting up my fist Multiplayer game. I was in the process of using Unity, but ran into a few hiccups, one of them being a lack of documentation, specifically tutorials, beyond player movement.


    So, what I am wondering is, with your asset and help service, is this just for the network itself? What about lobby issues? Lastly, in setting up a multiplayer game, you need 3 steps as far as I can see, please correct me if I am wrong.... a) a network server, accessing it running information over it etc. b) a lobby to gather players in prematch and set various conditions (team name etc) c) player controllers to transmit info across the network.


    If the above is true and those are the three chapters required, is this product only in regards to a)?


    Thank you
     
  39. Xuzon

    Xuzon

    Joined:
    Mar 21, 2014
    Posts:
    83
    Hello,
    First at all your plugin is awesome,
    but, I have some problems

    First
    one of my team run with this issue
    NATHelper: NAT Device not found
    (I emailed you with this issue)

    Second
    When I could connect with another person of my team UNET suddenly doesn't work at all, I have a stable build (with relay servers and lag of course XD) but when I add your plugin I have some strange behaviours:

    -An object spawned over the network in the server spawn in clients before they load the scene so it will be destroyed

    -My network transform doesn't work from the client to server (the client could see the position of the host's player but

    and something more
     
  40. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    @thegreatzebadiah

    I'm doing automatic matchmaking as soon as the game starts. Your plugin is accessing some external services like icanhazip and the facilitator, how do i know that everything is setup and your plugin is ready to go. OnDoneConnectingToFacilitator, Start(), nathelper.isActiveAndEnabled ?

    Many thanks.
     
  41. iddqd

    iddqd

    Joined:
    Apr 14, 2012
    Posts:
    501
    @thegreatzebadiah

    To test connecting to a Unity Relay match with only the MatchID, i changed the StartClientAll on line 89 in your
    ExampleNetworkManager.cs:


    Code (CSharp):
    1.      
    2. matchID = match.networkId;
    3. StartClientAll(null, null, 0, matchID, null, null, OnMatchJoined, "", 0, 0, false);
    4. // old: StartClientAll(match);
    5.  
    and in the ExampleNetworkManager Inspector i only selected "Relay" and "Use Unity Matchmaker".
    OnMatchJoined reports a success, but the client never connects.

    By the way, i'm using 5.4.2p4 - 5.4.2p3 fixed some multiplayer disconnect issues, so i upgraded:
    https://unity3d.com/unity/qa/patch-releases?version=5.4

    Can you reproduce this?
     
    Last edited: Nov 16, 2016
  42. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Hi, we're doing our first steps into Host Migration and I'm not sure how to set it up for the plugin.

    For the standard UNET Host Migration, I think you just need to have the Migration component attached (and then code everything and make sure it works properly, sure...), however for the plugin I guess I'll need to add the one that your provide (otherwise it throws a invalid type cast exception). Problem is, the custom migration component doesn't appear in Unity if I click the add component button.

    I've tried creating the component from code:

    Code (csharp):
    1.  
    2. GameObject go = Resources.Load<GameObject>("Network/MilkNetworkManager");
    3. GameObject instance = GameObject.Instantiate(go);
    4.  
    5. DontDestroyOnLoad(instance);
    6.  
    7. nm = instance.GetComponent<MilkNetworkManager>();
    8. NATTraversal.MigrationManager migration = nm.gameObject.AddComponent<NATTraversal.MigrationManager>();
    9.  
    10. // More initialization code, etc.
    11.  
    12. nm.StartHostAll(name, GameGlobals.MaxPlayerCount, true);
    13.  
    14.  
    And it seems to work properly on the host (as in, "no errors on startup"), however on the clients I get some "Unknown message ID" errors, so I guess I'm missing some kind of initialization. I don't see the class in the API website so there's no info there on how to set it up either.

    To sum it up: Any sample or procedure to start using host migration with this plugin?
     
  43. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Ok, disregard the previous message, I found the Host Migration tutorial.

    So, new bug report (I think):

    From time to time, disconnections are not properly handed. OnMulticlientDisconnect is called, but OnClientDisconnect isn't. If I'm not mistaken, OnMulticlientDisconnect is called when duplicate connections are dropped (such as punchthrough when a direct connection is established), so no action should be required on that callback.
    I don't have specific reproduction steps, it happens from time to time when I connect to a host (direct connection available) and then leave the game on the host (by calling StopHost()).

    Here's a log for the client when this happened:

    Code (csharp):
    1.  
    2. Joined: Milkstone.Game.Steam.Network.SteamSession
    3. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    4. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    5. UnityEngine.Logger:Log(LogType, Object)
    6. UnityEngine.Debug:Log(Object)
    7. <QuickJoin>c__Iterator63:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:135)
    8. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    9.  
    10. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 135)
    11.  
    12. NATHelper: Connected to Facilitator: 247698136285938780
    13. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    14. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    15. UnityEngine.Logger:Log(LogType, Object)
    16. UnityEngine.Debug:Log(Object)
    17. NATTraversal.NATHelper:OnDoneConnectingToFacilitatorInternal(UInt64, Packet)
    18. NATTraversal.<messageLoop>d__44:MoveNext()
    19. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    20.  
    21. (Filename: C:/buildslave/unity/build/Runtime/Export/Coroutines.cs Line: 17)
    22.  
    23. Lobby SteamID: 109775243734183546
    24. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    25. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    26. UnityEngine.Logger:Log(LogType, Object)
    27. UnityEngine.Debug:Log(Object)
    28. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:417)
    29. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    30.  
    31. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 417)
    32.  
    33. publicIP:XX.XXX.XX.XX
    34. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    35. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    36. UnityEngine.Logger:Log(LogType, Object)
    37. UnityEngine.Debug:Log(Object)
    38. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:423)
    39. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    40.  
    41. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 423)
    42.  
    43. internalIP:192.168.0.22
    44. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    45. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    46. UnityEngine.Logger:Log(LogType, Object)
    47. UnityEngine.Debug:Log(Object)
    48. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:424)
    49. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    50.  
    51. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 424)
    52.  
    53. publicIPv6:
    54. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    55. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    56. UnityEngine.Logger:Log(LogType, Object)
    57. UnityEngine.Debug:Log(Object)
    58. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:425)
    59. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    60.  
    61. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 425)
    62.  
    63. internalIpv6:2001:0:5ef5:79fd:2002:3d6c:aa67:d0e9
    64. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    65. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    66. UnityEngine.Logger:Log(LogType, Object)
    67. UnityEngine.Debug:Log(Object)
    68. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:426)
    69. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    70.  
    71. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 426)
    72.  
    73. guid:995296037788558358
    74. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    75. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    76. UnityEngine.Logger:Log(LogType, Object)
    77. UnityEngine.Debug:Log(Object)
    78. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:429)
    79. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    80.  
    81. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 429)
    82.  
    83. matchID:450359962737941071
    84. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    85. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    86. UnityEngine.Logger:Log(LogType, Object)
    87. UnityEngine.Debug:Log(Object)
    88. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:438)
    89. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    90.  
    91. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 438)
    92.  
    93. NATTraveral: Attempting to connect directly: 192.168.0.22
    94. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    95. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    96. UnityEngine.Logger:Log(LogType, Object)
    97. UnityEngine.Debug:Log(Object)
    98. NATTraversal.NetworkManager:directConnect(String, String, String, String)
    99. NATTraversal.NetworkManager:StartClientAll(String, String, UInt64, NetworkID, String, String, DataResponseDelegate`1, String, Int32, Int32, Boolean)
    100. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:457)
    101. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    102.  
    103. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 457)
    104.  
    105. OnStartClient
    106. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    107. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    108. UnityEngine.Logger:Log(LogType, Object)
    109. UnityEngine.Debug:Log(Object)
    110. MilkNetworkManager:OnStartClient(NetworkClient) (at Assets\Scripts\Network\MilkNetworkManager.cs:227)
    111. NATTraversal.NetworkManager:directConnect(String, String, String, String)
    112. NATTraversal.NetworkManager:StartClientAll(String, String, UInt64, NetworkID, String, String, DataResponseDelegate`1, String, Int32, Int32, Boolean)
    113. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:457)
    114. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    115.  
    116. (Filename: Assets/Scripts/Network/MilkNetworkManager.cs Line: 227)
    117.  
    118. MatchMakingClient Join :https://mm.unet.unity3d.com/json/reply/JoinMatchRequest
    119. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    120. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    121. UnityEngine.Logger:Log(LogType, Object)
    122. UnityEngine.Debug:Log(Object)
    123. UnityEngine.Networking.Match.NetworkMatch:JoinMatch(JoinMatchRequest, DataResponseDelegate`1) (at C:\buildslave\unity\build\Runtime\Networking\Managed\MatchMakingClient.cs:193)
    124. UnityEngine.Networking.Match.NetworkMatch:JoinMatch(NetworkID, String, String, String, Int32, Int32, DataResponseDelegate`1) (at C:\buildslave\unity\build\Runtime\Networking\Managed\MatchMakingClient.cs:180)
    125. NATTraversal.NetworkManager:StartClientAll(String, String, UInt64, NetworkID, String, String, DataResponseDelegate`1, String, Int32, Int32, Boolean)
    126. <JoinServer>c__Iterator66:MoveNext() (at Assets\Scripts\UI\Menu\QuickJoinScript.cs:457)
    127. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    128.  
    129. (Filename: Assets/Scripts/UI/Menu/QuickJoinScript.cs Line: 457)
    130.  
    131. NATTraveral: Client connected directly
    132. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    133. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    134. UnityEngine.Logger:Log(LogType, Object)
    135. UnityEngine.Debug:Log(Object)
    136. NATTraversal.NetworkManager:OnMultiClientConnectInternal(NetworkConnection)
    137. NATTraversal.NetworkManager:OnMultiClientConnectMsg(NetworkMessage)
    138. UnityEngine.Networking.NetworkConnection:InvokeHandler(Int16, NetworkReader, Int32) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:217)
    139. UnityEngine.Networking.NetworkConnection:InvokeHandlerNoData(Int16) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:199)
    140. UnityEngine.Networking.NetworkClient:Update() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:718)
    141. UnityEngine.Networking.NetworkClient:UpdateClients() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:950)
    142. UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:1073)
    143.  
    144. (Filename: C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs Line: 217)
    145.  
    146. OnClientConnect: 1 192.168.0.22
    147. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    148. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    149. UnityEngine.Logger:Log(LogType, Object)
    150. UnityEngine.Debug:Log(Object)
    151. MilkNetworkManager:OnClientConnect(NetworkConnection) (at Assets\Scripts\Network\MilkNetworkManager.cs:413)
    152. NATTraversal.NetworkManager:OnMultiClientConnect(NetworkConnection)
    153. NATTraversal.NetworkManager:OnMultiClientConnectInternal(NetworkConnection)
    154. NATTraversal.NetworkManager:OnMultiClientConnectMsg(NetworkMessage)
    155. UnityEngine.Networking.NetworkConnection:InvokeHandler(Int16, NetworkReader, Int32) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:217)
    156. UnityEngine.Networking.NetworkConnection:InvokeHandlerNoData(Int16) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:199)
    157. UnityEngine.Networking.NetworkClient:Update() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:718)
    158. UnityEngine.Networking.NetworkClient:UpdateClients() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:950)
    159. UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:1073)
    160.  
    161. (Filename: Assets/Scripts/Network/MilkNetworkManager.cs Line: 413)
    162.  
    163. Player connected: -1
    164. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    165. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    166. UnityEngine.Logger:Log(LogType, Object)
    167. UnityEngine.Debug:Log(Object)
    168. MilkNetworkManager:PlayerConnected(MilkNetworkPlayerBehaviour) (at Assets\Scripts\Network\MilkNetworkManager.cs:126)
    169. MilkNetworkPlayerBehaviour:Start() (at Assets\Scripts\Network\MilkNetworkPlayerBehaviour.cs:65)
    170.  
    171. (Filename: Assets/Scripts/Network/MilkNetworkManager.cs Line: 126)
    172.  
    173. Player connected: 0
    174. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    175. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    176. UnityEngine.Logger:Log(LogType, Object)
    177. UnityEngine.Debug:Log(Object)
    178. MilkNetworkManager:PlayerConnected(MilkNetworkPlayerBehaviour) (at Assets\Scripts\Network\MilkNetworkManager.cs:126)
    179. MilkNetworkPlayerBehaviour:Start() (at Assets\Scripts\Network\MilkNetworkPlayerBehaviour.cs:65)
    180.  
    181. (Filename: Assets/Scripts/Network/MilkNetworkManager.cs Line: 126)
    182.  
    183. Match info received: 450359962737941071 -
    184. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    185. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    186. UnityEngine.Logger:Log(LogType, Object)
    187. UnityEngine.Debug:Log(Object)
    188. MilkNetworkManager:OnMatchJoined(Boolean, String, MatchInfo) (at Assets\Scripts\Network\MilkNetworkManager.cs:117)
    189. UnityEngine.Networking.Match.NetworkMatch:OnMatchJoined(JoinMatchResponse, DataResponseDelegate`1) (at C:\buildslave\unity\build\Runtime\Networking\Managed\MatchMakingClient.cs:220)
    190. UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator0`2:MoveNext() (at C:\buildslave\unity\build\Runtime\Networking\Managed\MatchMakingClient.cs:426)
    191. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    192.  
    193. (Filename: Assets/Scripts/Network/MilkNetworkManager.cs Line: 117)
    194.  
    195. OnHolePunchedClient Listen:0 Connect:0 Success:False
    196. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    197. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    198. UnityEngine.Logger:Log(LogType, Object)
    199. UnityEngine.Debug:Log(Object)
    200. MilkNetworkManager:OnHolePunchedClient(Int32, Int32, Boolean) (at Assets\Scripts\Network\MilkNetworkManager.cs:166)
    201. NATTraversal.NATHelper:listenForPunchthroughResponse(Packet)
    202. NATTraversal.<messageLoop>d__44:MoveNext()
    203. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    204.  
    205. (Filename: Assets/Scripts/Network/MilkNetworkManager.cs Line: 166)
    206.  
    207. NATHelper: Unexpected raknet message received: ID_NAT_PUNCHTHROUGH_FAILED
    208. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    209. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    210. UnityEngine.Logger:Log(LogType, Object)
    211. UnityEngine.Debug:LogWarning(Object)
    212. NATTraversal.NATHelper:listenForPunchthroughResponse(Packet)
    213. NATTraversal.<messageLoop>d__44:MoveNext()
    214. UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)
    215.  
    216. (Filename: C:/buildslave/unity/build/Runtime/Export/Coroutines.cs Line: 17)
    217.  
    218. OnMultiClientDisconnect
    219. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    220. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    221. UnityEngine.Logger:Log(LogType, Object)
    222. UnityEngine.Debug:Log(Object)
    223. MilkNetworkManager:OnMultiClientDisconnect(NetworkConnection) (at Assets\Scripts\Network\MilkNetworkManager.cs:325)
    224. NATTraversal.NetworkManager:OnMultiClientDisconnectMsg(NetworkMessage)
    225. UnityEngine.Networking.NetworkConnection:InvokeHandler(Int16, NetworkReader, Int32) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:217)
    226. UnityEngine.Networking.NetworkConnection:InvokeHandlerNoData(Int16) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkConnection.cs:199)
    227. UnityEngine.Networking.NetworkClient:Update() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:753)
    228. UnityEngine.Networking.NetworkClient:UpdateClients() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:950)
    229. UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate() (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkIdentity.cs:1073)
    230.  
    231. (Filename: Assets/Scripts/Network/MilkNetworkManager.cs Line: 325)
    232.  
    233. NATHelper: NAT Device not found
    234. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    235. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    236. UnityEngine.Logger:Log(LogType, Object)
    237. UnityEngine.Debug:LogWarning(Object)
    238. NATTraversal.NATHelper:doneFindingNATDeviceInternal(NatDevice, Boolean, Action`1)
    239. NATTraversal.<>c__DisplayClass46_0:<findNatDevice>b__0(Task`1)
    240. System.Threading.Tasks.<>c__DisplayClass10:<ContinueWith>b__f(Object)
    241. System.Threading.Tasks.Task:InnerInvoke()
    242. System.Threading.Tasks.Task:Execute()
    243. System.Threading.Tasks.Task:ExecutionContextCallback(Object)
    244. System.Security.SecurityContext:Run(SecurityContext, ContextCallback, Object) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Security/SecurityContext.cs:150)
    245. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Threading/ExecutionContext.cs:150)
    246. System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
    247. System.Threading.Tasks.Task:ExecuteEntry(Boolean)
    248. System.Threading.Tasks.ThreadPoolTaskScheduler:TaskExecuteWaitCallback(Object)
    249.  
    250. (Filename: /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Security/SecurityContext.cs Line: 150)
    251.  
    252. NetworkClient Send when not connected to a server
    253. UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    254. UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    255. UnityEngine.Logger:Log(LogType, Object)
    256. UnityEngine.Debug:LogError(Object)
    257. UnityEngine.Networking.NetworkClient:Send(Int16, MessageBase) (at C:\buildslave\unity\build\Extensions\Networking\Runtime\NetworkClient.cs:540)
    258. WhiteNoiseNetworkLogic:SendChat(String) (at Assets\Scripts\Network\WhiteNoiseNetworkLogic.cs:181)
    259. ChatFilter:FilterText(String, Int32) (at Assets\Scripts\UI\HUD\ChatFilter.cs:133)
    260. MilkUIChat:submitType(String, Int32) (at Assets\Milkstone\Scripts\UI\MilkUIChat.cs:94)
    261. MilkUIChat:Submit() (at Assets\Milkstone\Scripts\UI\MilkUIChat.cs:133)
    262. EventDelegate:Execute() (at Assets\ThirdParty\NGUI\Scripts\Internal\EventDelegate.cs:476)
    263. EventDelegate:Execute(List`1) (at Assets\ThirdParty\NGUI\Scripts\Internal\EventDelegate.cs:644)
    264. UIInput:Submit() (at Assets\ThirdParty\NGUI\Scripts\UI\UIInput.cs:1180)
    265. UIInput:Update() (at Assets\ThirdParty\NGUI\Scripts\UI\UIInput.cs:766)
    266.  
    267. (Filename: Assets/Scripts/Network/WhiteNoiseNetworkLogic.cs Line: 181)
    268.  
     
  44. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Did you try connecting to the facilitator even though it appears to bind to the wrong address? I think on some systems it outputs the wrong ip but still functions properly. If it's really not working for you I can see about reworking it so you can pass in a specific address to bind to, shouldn't be too hard.

    You've pretty much got it down. Once the port is open it's a regular old direct connection, the Facilitator isn't involved at all after the initial handshake.
     
  45. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @WaaghMan I've got those two older problems resolved, I'll be looking into your latest issue in a bit. Hopefully I'll have a new build for you to test in a day or so. I think I've already got some ideas on what is causing the latest thing. Glad you got host migration figured out, it honestly still confuses me.
     
  46. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Unfortunately host migration doesn't work with the relays at the moment. See the cryptic comment at the very bottom of this page: https://docs.unity3d.com/Manual/UNetHostMigration.html

    It should work just fine 'over the net' though with either direct connections via port forwarding or punch-through.
     
    Last edited: Nov 18, 2016
  47. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    You shouldn't have to wait for everything to be set up. Just call StartHostAll() or StartClientAll(), the plugin will automatically wait for things to be initialized when necessary.
     
    iddqd likes this.
  48. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Nice, eager to test the new version :)

    Advancing on host migration, it's finally somewhat working with two peers (the original host leaving and the client that becomes the new host), however we need to update the Steam lobby with the new host address etc., so people can still join the game. There's a minor problem with that, the NetworkManager.hostInternalIP is not updated when BecomeNewHost() is called, so it's still pointing to the original host and I don't see a way to get our own IP address. Same could happen with external IPs, haven't tried with clients running in different networks yet.
     
  49. bekilo

    bekilo

    Joined:
    Apr 22, 2013
    Posts:
    3
    Hey, new purchaser here, having some difficulties getting your plugin to work:

    I tried modifying my StartHost statement to StartHostAll and after tweaking some parameters i got this result:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. NATTraversal.NetworkManager.StartHostAll (System.String matchName, UInt32 maxPlayers, Boolean advertise, System.String password, Int32 eloScore, Int32 requestDomain, UnityEngine.Networking.Match.DataResponseDelegate`1 callback) (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:289)
    3. SpecialNetworkManager.Start () (at Assets/Chash/SpecialNetworkManager.cs:48)
    4.  
    Here is a segment from my Network Manager script:

    Code (CSharp):
    1. public override void Start()
    2.     {
    3.         MatchParams mp = MetaManager.matchParamsCurrent;
    4.         if (mp.host)
    5.         {
    6.            
    7.             Debug.Log(MetaManager.matchParamsCurrent);
    8.             StartHostAll("1234", 2);//this line is line 48, which produces exactly the same error as
    9.             return;
    10.             StartHostAll(MetaManager.matchParamsCurrent.mid,//this line
    11.                 2, true, MetaManager.matchParamsCurrent.pass, 0, 1,
    12.                 delegate (bool sc, string exi, MatchInfo mi) {
    13.                     if (!sc) GameManager.showFailedConnection();
    14.                     StartCoroutine(getOrSetNetworkID(mi.networkId.ToString(),delegate{ }));
    15.             });
    16.            
    17.             GameManager.showWaitingForOtherPlayer();
    18.  
    19.         }
    20.         else
    21.         {
    22.             GameManager.showWaitingForOtherPlayer();
    23.             StartCoroutine(getOrSetNetworkID("", delegate
    24.             {
    25.                 StartCoroutine(joinCoroutine());
    26.  
    27.             }));
    28.         }
    29.         Timing.CallDelayed(connectionTimeout, delegate {
    30.             if (!GameManager.gameStarted)
    31.             {
    32.                 GameManager.showFailedConnection();
    33.             }
    34.             else
    35.             {
    36.                 Debug.Log("Enjoy your game!");
    37.             }
    38.         });
    39.  
    40.     }
    So i figured you did something special to the Start function and added base.Start(); just to be sure to the very top of my override:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. NATTraversal.NetworkManager.Start () (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:689)
    3. SpecialNetworkManager.Start () (at Assets/Chash/SpecialNetworkManager.cs:42)
    Line 42 is base.Start();



    I don't call StartMatchMaker(); in Awake() anymore but i tried adding it anyway and still same errors.

    External IP Source I set to 'grabblesgame.com' for testing.
    External IPv6 Source is set to 'grabblegames.com'

    I tried the example and it worked there, not sure what I am doing wrong pls help
     
  50. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245