Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

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

  1. HappyBadgerStudio

    HappyBadgerStudio

    Joined:
    May 6, 2014
    Posts:
    19
    Awesome!! Thank you so much, the OnMultiClientDisconnect() is indeed the event I was missing.

    and for sure, I will send you an email, thank you so much again. :D
     
  2. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Just so you are aware, each physical client can have multiple NetworkClient instances (one for each enabled connection type, direct / punchthrough / relay) so OnMultiClientDisconnect() may be called multiple times and you may not want to treat every call as a real disconnect depending on if the other client's are still connected or not (or if punchthrough is still being attempted). Basically it's a pain to handle correctly.

    The best solution is going to be to hope that the latest build fixes the issue, but at least now you can debug a little more effectively :)

    P.S. Please don't forget to rate / review the asset on the asset store! Thank you.
     
    HappyBadgerStudio likes this.
  3. HappyBadgerStudio

    HappyBadgerStudio

    Joined:
    May 6, 2014
    Posts:
    19
    Will do, thank you for the advice!
    The build you sent me already seems to have solved the other issue. Instead of the host destroying all lobby players (if it did at all), it is just destroys itself, and leaves the other client lobby players. So I assume the next step is when that happens I handle the host migration part.

    If I run into any more bugs or anything I will report them.

    Thank you a ton again!
     
  4. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Updated connection statistics with the proposed changes applied:

    Host game:

    * Successful with NAT and Relay enabled: 99,43% (up 2%)
    * Successful without NAT (could not get a guid in time or something else failed): 0,32%
    * Successful without Relay (could not get a match ID in time): 0,24%

    Join game:
    * Successful through NAT: 29,69% (up 3%)
    * Failed with Timeout: 22,75% (up 3%)
    * Cancelled by user (probably a Timeout): 8,62% (down 10%)
    * Succesful through Relay: 19,79% (up 2%)
    * Successful through Direct connection: 17,47% (up 3%)
    * Error (exception or unexpected state): 1,80%
    * Successful but could not determine if it's relay, NAT or Direct (should not really happen!): 0,54%

    The main improvement in this version was that timeouts were detected better and faster, so the number of user cancels went drastically down, although the number of timeouts increased as a result. We still have a rather high fail ratio (~30%), but it's smaller than before. I'm worried that Relay isn't being able to work better, and I'm not sure why. On approximately 20% of the connection attempts, a "Could not join match - failed: Failed enumerating host node id appId=1917202. Match is likely unavailable, please select another to join." is reported.

    I tried to detect relay disconnections on the host with the NetworkTransport.ReceiveRelayEventFromHost() method, and on very few instances (just 9 times), the method did report a disconnection, but more often that not, there's no way to detect that the Relay connection has been lost. I don't know if this is the plugin's fault or not, since it's not something we can reproduce in our tests anyway.
     
  5. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    It really sounds like the host just isn't hosting via relay anymore when the clients try and connect. Hard to say why though. Maybe they get disconnected because of the relay bandwidth limit? Maybe they are disconnecting manually but for some reason the match is still returned via whatever matchmaking you're using?
     
  6. HappyBadgerStudio

    HappyBadgerStudio

    Joined:
    May 6, 2014
    Posts:
    19
    Hello!

    Quick question, not sure if this is a bug or not, but I am running into an issue.

    Quick run down (this can be replicated in the example managers) NATLobbyManager and NetworkManagerHUD.
    Create a match, have a client join it.
    Make client leave the match, then host leave the match.

    Make same host create a new match, and then have the client try to join it, an error will be thrown:
    NullReferenceException: NATTraversal.NetworkManager.OnMatchJoined().

    If we try another experiment, where I try to replicate my exact issue,
    Create a match, have a client join it.
    Make client leave the match, then host leave the match.
    Client now creates a match, and the old host joins (now their roles are swapped), I get this error in the example scene for the client
    Unknown message ID 11 connId:1
    Unknown message ID 32764 connId:1

    This was with me trying to replicate my current problem with just the NATLobbyManager and NetworkManagerHUD.

    My current issue is this - Host creates a match with steam, client joins it, they play for a little bit, then client leaves the game, and then the host.

    The old client then creates a match, and the old host joins it (now their roles are swapped) but OnServerAddPlayer is only called for the new host, and not when the new client joins (When it is usually called everytime a player joins the room). OnServerConnect and OnLobbyServerConnect are triggered, but no lobby players are created for the new client.

    I'm trying to consolidate all the information as well as I can. Can you replicate these issues?
     
  7. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Version 1.51 Released

    Changes include:
    • Fixed external IP timouts (and some related output)
    • Fixed some off-by-one issues with max connects / max players
    • Fixed issue with dropped messages while negotiating connections.
    • Added lifetime parameter to map port method.
    • Added support for 5.6
    Got some good fixes in this one for some especially annoying / hard to catch bugs. Keep em comin' guys :)

    I'm going to be out of town visiting family for about a week so I won't be responding here. Keep posting though, and as always feel free to shoot me an email. I'll get to everything as soon as I can when I get back.

    @HappyBadgerStudio Sure sounds like a bug, unfortunately I won't be able to look into it until I get back.
     
  8. lafain

    lafain

    Joined:
    Aug 12, 2012
    Posts:
    6
    My client will successfully connect via punch-through, but seems to stop at or after OnClientConnect() (OnStartLocalPlayer() never gets called). When my game is behind the same router it connects directly and the game starts flawlessly. Is there anything that does/doesn't gets called when it connects directly versus punch-through? Thanks!

    edits:
    punchThroughCon.isReady and isConnected are true;

    I'm calling StartClientAll() like this, if it matters.
    StartClientAll(G.externalHostIP, G.internalHostIP, _hostGUID);
     
    Last edited: Mar 25, 2017
  9. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @lafain The main dude is out for a bit so I've no clue what you are talking about but our facilitator is currently down so maybe it's that?


    So, our facilitator is down at the moment and I've no clue how to restart it.

    I'll poke around but we may just have to wait until the main dude gets back from family.

    There's information in the FAQ and DOCs about how to set up your own facilitator for those of you looking to get started on that now. Had to happen sometime. :)
     
  10. lafain

    lafain

    Joined:
    Aug 12, 2012
    Posts:
    6
    Actually, ya'lls facilitator going down finally caused me to figure out what was wrong with my windows based EC2 facilitator. (I messaged Zebediah a while back ago about it. Turns out it was Windows Firewall so possibly add that to the FAQ. Drove me bananas trying to figure it out.)

    Though, kudos to you, second-in-command, for replying. Getting any kind of response (at this crucial juncture for me) is a huge relief. This is the last little bit holding back my indie MMOFPS. After this, I think I'll be home free.
     
  11. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    Our facilitator is back up and running for all your testing purposes.

    I would like to take this as an opportunity to remind you all that you should be setting up your own anyway after the initial testing to see if everything works. Ours has no guaranteed up time, but we do use the same one ourselves so we keep it up pretty well.
     
  12. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I recently added the latest version of the plugin to my game, and had someone email me stating that he had repeated difficulties creating or joining a game.

    I had him revert to a previous version of my game that was using the previous version of NAT Traversal, and he had no problems. I don't see anything in his output log that might have caused this, though I'll likely send him a version of my game that prints a more detailed output log. One thing to note is that his output logs for the current (non-working) version and previous (working) version had the following statements:

    Code (csharp):
    1. NATHelper: Something went wrong mapping port 50000->50000 (Udp)
    2. NATHelper: Something went wrong mapping port 50000->50000 (Tcp)
    (50000 is the port I use rather than 7777)

    In the non-working version, he reaches "OnClientConnect", but stops short of the following line, which only takes place in the earlier version:
    Code (csharp):
    1. MatchMakingClient Create :https://mm.unet.unity3d.com/json/reply/CreateMatchRequest
    Is it possible that something in the latest version might have caused this? Sorry I don't have more details at the moment, just curious if this sort of thing seems possible with the changes to the most recent version.

    Also of note, there is only one person who has reported the issue so far, and I tend to have a decent number of online games going at once.

    Edit: Since I first posted this, a bunch more people reported the issue to me. I had to revert to the previous version of the plugin, which judging from response so far, seems to have fixed things. So, there's definitely something going on with the latest version that's causing problems for a portion of players. If need be, I can create a version of my game that outputs a "Debug" log from the NetworkManager, and have someone try it out and send me a log.
     
    Last edited: Mar 27, 2017
  13. Fuestrine

    Fuestrine

    Joined:
    Feb 13, 2013
    Posts:
    587
    @Doghelmer Glad to hear a revert fixed it. The main tech dude is with family for the week but he'll see all this when he gets back and fix things up for ya'll. Just wanted you and others who may come across this to know that we got the message and to revert to the previous version if things are acting up.
     
  14. HenkeBenkes

    HenkeBenkes

    Joined:
    Sep 15, 2015
    Posts:
    11
    I just downloaded the asset and ran the example scene. After 10 seconds(External IP Timeout) i got this error:
    NullReferenceException: WWW class has already been disposed.

    My http://ipv6.icanhazip.com does not work but ipconfig confirms my ipv6 adress. Anyway I don't think it should crash because of this?

    I tried on two different computers, two different wifi's and one wired connection.

    Unity version: 5.5.1f1

    Full error log:
    NullReferenceException: WWW class has already been disposed.
    NATTraversal.NetworkManager.handleExternalIPResponse (UnityEngine.WWW www, System.String& ip)
    NATTraversal.NetworkManager+<getExternalIPv6>d__120.MoveNext ()
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
     
  15. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    New issue: An user reported an engine crash ( GetThreadContext failed ) with the following call stack:

    Code (csharp):
    1.  
    2. 0x74C08292 (KERNELBASE) DebugBreak
    3. 0x1010D9FF (mono) unity_mono_reflection_method_get_method
    4. 0x1010DA39 (mono) unity_mono_reflection_method_get_method
    5. 0x1010AFAD (mono) unity_mono_reflection_method_get_method
    6. 0x1010B7F8 (mono) unity_mono_reflection_method_get_method
    7. 0x1010B934 (mono) unity_mono_reflection_method_get_method
    8. 0x1010BAA0 (mono) unity_mono_reflection_method_get_method
    9. 0x1010AAA9 (mono) unity_mono_reflection_method_get_method
    10. 0x1010F0B2 (mono) unity_mono_reflection_method_get_method
    11. 0x1005EEE0 (mono) mono_object_new_alloc_specific
    12. 0x1005FEBF (mono) mono_object_new_specific
    13. 0x06844840 (Mono JIT Code) (wrapper managed-to-native) object:__icall_wrapper_mono_object_new_specific (intptr)
    14. 0x069219A9 (Mono JIT Code) System.Linq.Enumerable:CreateWhereIterator<object> (System.Collections.Generic.IEnumerable`1<object>,System.Func`2<object, bool>)
    15. 0x069218F1 (Mono JIT Code) System.Linq.Enumerable:Where<object> (System.Collections.Generic.IEnumerable`1<object>,System.Func`2<object, bool>)
    16. 0x0692AB55 (Mono JIT Code) Open.Nat.Searcher:Receive (System.Threading.CancellationToken)
    17. 0x069299B1 (Mono JIT Code) Open.Nat.Searcher/<>c__DisplayClass4_0:<Search>b__0 (object)
    18. 0x06929905 (Mono JIT Code) System.Threading.Tasks.Task:InnerInvoke ()
    19. 0x06929777 (Mono JIT Code) System.Threading.Tasks.Task:Execute ()
    20. 0x06929724 (Mono JIT Code) System.Threading.Tasks.Task:ExecutionContextCallback (object)
    21. 0x06928FD5 (Mono JIT Code) System.Security.SecurityContext:Run (System.Security.SecurityContext,System.Threading.ContextCallback,object)
    22. 0x06928C03 (Mono JIT Code) System.Threading.ExecutionContext:Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object)
    23. 0x069289DB (Mono JIT Code) System.Threading.Tasks.Task:ExecuteWithThreadLocal (System.Threading.Tasks.Task&)
    24. 0x069285DB (Mono JIT Code) System.Threading.Tasks.Task:ExecuteEntry (bool)
    25. 0x069283CD (Mono JIT Code) System.Threading.Tasks.ThreadPoolTaskScheduler:TaskExecuteWaitCallback (object)
    26. 0x068400BF (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this___object (object,intptr,intptr,intptr)
    27. 0x100F172A (mono) mono_set_defaults
    28. 0x1005D839 (mono) mono_runtime_invoke
    29. 0x10062693 (mono) mono_runtime_invoke_array
    30. 0x1006292A (mono) mono_runtime_invoke_array
    31. 0x1007BA3F (mono) mono_security_set_mode
    32. 0x1007C238 (mono) mono_security_set_mode
    33. 0x1007F254 (mono) mono_thread_interruption_request_flag
    34. 0x1010C7DC (mono) unity_mono_reflection_method_get_method
    35. 0x772338F4 (KERNEL32) BaseThreadInitThunk
    36. 0x77B55DE3 (ntdll) RtlUnicodeStringToInteger
    37. 0x77B55DAE (ntdll) RtlUnicodeStringToInteger
    It was the first attempt to join the game after the game started. External IP was properly detected, but the game being joined didn't have a proper Match ID, so relay was disabled (Don't think there's a relation but just in case).
     
  16. stmetz

    stmetz

    Joined:
    Jan 20, 2017
    Posts:
    1
    Hi guys!

    Hate to pile on, because I know thegreatzebediah is out on vacay, but I am running into some issues regarding a few edges cases. I have been testing my networking on a school campus, and their public Student network has some strong firewalling and AP isolation that is revealing some issues when network conditions are less than ideal... I am hoping maybe you all have some thoughts on how to solve?

    1) When users change their internet connection while the application is running (say, by joining another wireless network), after loading the lobby scene where the NATLobbyManager is initialized, their external and internal IPs changes, but I don't believe these changes are picked up by the NATTraversal system, and therefore direct connect and punchthroughs fail

    2) There is nothing to stop players behind firewalls from unwittingly creating games which will be listed by the Unity matchmaking service. All clients attempting to join will timeout, resulting in un-joinable matches listed by the unity matchmaking service.

    3) As a client, attempting to connect to a game behind an impenetrable firewall: When one selected connection service is unavailable, such as if 'Use Relay' is checked but Unity relay is unavailable, or 'Use Punchthrough' is checked, but the facilitator is unreachable, I find that when the remaining connections timeout, OnClientDisconnect is not called, as it would be under normal circumstances.

    The last seems like maybe an internal issues with the NATTraversal NetworkManager? If anyone has any ideas on how to proceed please let me know! The road to getting my game network enabled has been a long one, and these are some of the last issues to be resolved... Thanks in advance!

    Steve
     
  17. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Not exactly a bug, but something worth noting:

    I think OnServerDisconnect() can be called on cases where the client isn't really disconnecting, if just one of the 3 connection methods is disconnected. Not saying the plugin is doing something wrong, but we actually did (treating OnServerDisconnect as a player disconnection, when it's not always the case). Not sure if there's a way to check if the connection was actually the last one when overriding OnServerDisconnect.

    Saying this because two players were given the same ID (a byte we assign to handle players) by the server, which I think could only happen if the server thought the player was gone.
     
  18. FlyingHighUp

    FlyingHighUp

    Joined:
    Apr 23, 2012
    Posts:
    16
    Hey again, I've spent a couple days trying to build RakNet for iOS/Android :)

    ~I'm trying to replicate the RakNet.bundle you built for OSX first. I've managed to build libRakNet.a for iOS in Xcode, and I've built the Swig C# files in a separate project, but I'm not sure how you combined them into RakNet.bundle. How did you set that up? (Did you compress it? I'm having issues trying to extract what you have in there for reference ;) )~

    Making RakNet for iOS should be as simple as changing the base library from macOS to iOS in your XCode project, so if you already have it, I'm sure iOS compatibility should be two clicks away.


    I got it to build on OSX. Also I lied, iOS isn't actually that simple because it's linked differently. Gimme a bit...

    Android is a different beast, which I'm going to try and tackle next.
    Edit: I've managed to build Android's libRakNet.so. But when Unity starts up on the device, I get
    Code (CSharp):
    1.  
    2. Unable to lookup library path for 'libc', native render plugin support disabled.
    3. E/Unity   (20744): Unable to find libc
    4. I/Unity   (20744): EntryPointNotFoundException: SWIGRegisterExceptionCallbacks_RakNet
    5. I/Unity   (20744):   at (wrapper managed-to-native) RakNet.RakNetPINVOKE/SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_RakNet
    6. ...
    7.  
    It can't find libc, which causes everything to fail. It seems to find my libRakNet.so though. Have you seen this before by chance? My best guess is that I'm compiling for the wrong version of Android (I'm targeting android-9).

    Edit: I got Android to work! Still working on iOS though. Gimmie a bit...
     
    Last edited: Apr 6, 2017
  19. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I have a similar situation. I believe this means your computer / network interface supports ipv6 but your service provider does not.

    I'm not sure why you're getting that error though. It should just be a nice friendly message like: "NATTraversal: Failed to fetch external IP: Could not resolve host: ipv6.icanhazip.com"

    I just added a try { } catch { } around it to swallow any exceptions so it should be fixed in the next release. Shoot me an email at the support email if you'd like a new build immediately.
     
  20. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Regarding IPv6: We added this check to look for people with IPv6 addresses:
    Code (csharp):
    1.  
    2. if ((nm.externalIP != null) && nm.externalIP.Contains(':'))
    3.        Debug.LogError("Public IP is in IPv6 format!");
    4.  
    This happens some times (~1.5% of the host attempts).

    We even changed the IPv6 fetch address to be the same as the IPv4 (http://icanhazip.com), but even with that we're seeing this result.
     
  21. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I think I've got a fix for this. I reworked code so that onHolePunched callback will be called on the main thread instead of the thread that is created for port mapping. Should be fixed in the next release.
     
  22. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Changing internet connections is going to trigger a disconnect no matter what as far as I know. Host migration is probably your best bet for handling that gracefully.

    Honestly not sure what to do about that other than try and join a different match if joining fails. If you come up with a good solution let me know though! Maybe some way of detecting firewall settings or trying to connect to a potential host from an external server before allowing them to create the match or something?

    Sounds like a bug. You may be able to work around it by overriding OnMultiClientDisconnect(). I'll mess with my firewall settings and see if I can recreate the issue though. It sounds like something I'm doing wrong.
     
  23. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I applaud your efforts but unfortunately I don't recognize that libc error. It's the exact kind of headache I would expect though so you're probably on the right track :)
     
  24. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Make sure the externalIPSource is set to http://ipv4.icanhazip.com

    That was supposed to be fixed in the latest release but maybe I messed it up.
     
  25. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Yeah, kind of confusingly designed on my part. The way to check if the disconnect is a real disconnect is to check if there is another connection from the same client:
    NetworkConnection otherCon = checkForAnotherConnectionFromTheSameClient(conn, ConnectionType.DIRECT | ConnectionType.PUNCHTHROUGH);

    if otherCon == null then you should treat it as an actual player disconnect.
     
  26. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    This seems not good. The only way I can see for it to not create the match is if connectRelay and useUnityMatchmaking are both false. Otherwise I would think it would throw some error at least. Maybe somehow those checkboxes got unchecked in the update? If you can get more output or narrow down the problem at all it would definitely help. I'm testing on my end but so far the latest update seems to be working.
     
    Last edited: Apr 6, 2017
  27. mightybob

    mightybob

    Joined:
    Mar 23, 2014
    Posts:
    75
    Hey, so I don't currently have a separate server to put the Facilitator on. Is there, by any chance, a Facilitator already running on your website that I can use for testing/development?
     
  28. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
  29. gabmedalv

    gabmedalv

    Joined:
    Sep 21, 2015
    Posts:
    6
    We are currently working on a game that uses NATTraversal+Steamworks for internet games and Unity’s builtin NetworkManager (Actually NetworkLobbyManager) for LAN games.
    Both scenarios works fine independently, however, we have a problem trying to create a LAN game after playing an internet game.

    The LAN host is created OK but the client gets the message “NetworkManager detected a script reload in the editor. This has caused the network to be shut down.” when trying to connect.
    Do you know if it’s necessary to clean or shutdown something in particular after invoking StopClient/StopHost in our NATTraversal NetworkManager implementation in order to avoid this error?

    Thanks in advance.
     
  30. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @gabmedalv That's one I've never seen before. Usually that means you edited a file while running the game in the editor. Maybe you've got some other code or third party asset / tool that is modifying files?
     
  31. FlyingHighUp

    FlyingHighUp

    Joined:
    Apr 23, 2012
    Posts:
    16
    Hey again guys!

    I went through 4 days of pure DLL hell to add iOS and Android support to the framework. I’ve tested it in the Example scene, but I’m not sure if everything works. If people could test it with their bigger projects that would be great.

    I simply built Raknet for iOS and Android. It also required me to write a special RakNetSwig.dll for iOS. It requires iOS 10.3+ (The Latest) or Android 9+

    To try it out,
    1. Import "NAT Traversal for UNET" from The Asset store
    2. Download + decompress this .zip
    https://drive.google.com/open?id=0B7cKeCSpjuApVktvRFhDRm5zY0U
    3. Place the contents in Assets/Plugins/
    4. Locate “Assets/Plugins/NAT Traversal for UNET/RakNetSwig.dll”. Uncheck “Any Platform” and check every platform except for iOS. Just checking “exclude iOS” causes collisions during build.
    5. Build and run your game on iOS or Android.

    Seems to work fine on Android, but I get "Nat Device Not Found" on my iPhone. Not sure if it's just me, because I swear it worked before...

    If you want to build the files yourself, download the source projects here:
    https://drive.google.com/open?id=0B7cKeCSpjuApRVNaalBuMGFvT1U
    Read the “HowToBuild.txt” document if you want to start from scratch. Use this over RakNet's official tutorials, because they don't tell you about tons of specific requirements. It’s really long, so I didn’t paste it here to save space.
     
    Last edited: Apr 6, 2017
    thegreatzebadiah likes this.
  32. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    Thank you, maybe the prefab value was already overriden by Unity.
     
  33. WaaghMan

    WaaghMan

    Joined:
    Jan 27, 2014
    Posts:
    245
    On the matchmaking issue ( the error "Could not join match - failed: Failed enumerating host node id appId=1917202. Match is likely unavailable, please select another to join" ) that we were having since release, I just found this info:

    So I guess it just was because players of different regions (and thus different matchmaking servers) were trying to join games from a different one.

    I'll see if there's a way to determine which server was used to create the match, and post that info in the Steam lobby.
     
    thegreatzebadiah likes this.
  34. brend0r

    brend0r

    Joined:
    Mar 27, 2017
    Posts:
    5
    Hi, we're getting the same issue as the guy earlier in this thread - when there's a missing symbol in the Linux version of RakNet.so. Specifically:
    0000000000000000 *UND* 0000000000000000 _ZplRKN6RakNet10RakWStringES2_
    This results in the following exception when linking the library:
    Couldn't open Assets/Plugins/x86_64/RakNet.so, error: Assets/Plugins/x86_64/RakNet.so: undefined symbol: _ZplRKN6RakNet10RakWStringES2_
    NATTraversal.<connectToNATFacilitator>d__45:MoveNext() (at E:\_Noble Whale\NAT Traversal Stuff\NAT Traversal DLL\NATTraversalForUNET\NATHelper.cs:341)
    NATTraversal.<connectToNATFacilitator>d__45:MoveNext() (at E:\_Noble Whale\NAT Traversal Stuff\NAT Traversal DLL\NATTraversalForUNET\NATHelper.cs:311)

    And then Unity crashes due to:

    Receiving unhandled NULL exception
    Launching bug reporter
    #0 0x007ffc924d5200 in funlockfile
    #1 0x007ffc924d57a8 in RakNet::RakPeer::GetIncomingPassword(char*, int*)
    #2 0x007ffc924d57b0 in CSharp_RakPeerInterface_Connect__SWIG_5

    Any idea why the symbol is missing in the RakNet library?
     
  35. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @brendor I wish I knew. I'll try and find some time to do some more linux testing, it has definitely been a while. In the meantime maybe @FlyingHighUp can help you out. Seems like he recently had some luck compiling raknet for linux.
     
  36. FlyingHighUp

    FlyingHighUp

    Joined:
    Apr 23, 2012
    Posts:
    16
    @brendor
    While I haven't compiled to Linux 64 yet, "_ZplRKN6RakNet10RakWStringES2_" looks like a mangled C++ method name. Not really sure what could be causing that, but my best guess is was RakNetSwig.dll was compiled with debug information and RakNet.so was built in release. Or vice versa. I would try rebuilding both of them.

    I would do it myself, but I have to make up for the time I took to get Android/iOS working. So probably not for another week.
     
  37. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @FlyingHighUp That sounds like just the sort of thing I would mess up. I'll try and get new linux libraries compiled asap but it will probably be a few days at least.
     
  38. brend0r

    brend0r

    Joined:
    Mar 27, 2017
    Posts:
    5
    Thanks for the quick response @thegreatzebadiah - you can check if the symbol is there easily via
    Code (CSharp):
    1. objdump RakNet.so -t | grep RakWString
    if you see any *UND* lines, the library is missing compiled code for these symbols and it won't link.
    I could compile it myself, but it would be time consuming and you already have the RakNet+SWIG project set up (maybe you could put it somewhere so I can compile it and try to get it working).
    @FlyingHighUp - I don't think that's the case, because RakNet.so is missing the symbol altogether - as if only declaration was exported, but the actual definition was not compiled, so it seems like some kind of misconfiguration, but I'm not sure if RakNetSwig.dll has anything to do with this - I believe the library with missing symbols would not link with either Release or Debug (and the symbol does not seem to be some debug-specific function)
    It is indeed a mangled C++ function, which demangles to
    Code (CSharp):
    1. operator+(RakNet::RakWString const&, RakNet::RakWString const&)
     
  39. brend0r

    brend0r

    Joined:
    Mar 27, 2017
    Posts:
    5
    Also, can we get a OSX version of the RakNet.dll? :)
     
  40. FlyingHighUp

    FlyingHighUp

    Joined:
    Apr 23, 2012
    Posts:
    16
    @brendor
    Very keen eye :eek:! It seems you know more about this than I do.

    Funny you bring up that specific method in RakWString.h; when I was building iOS/Android, it was quite problematic. Depending on what compiler I used, it didn't compile because it was missing a definition. Sometimes I got away with commenting it out, but in the end I kept it in.

    My XCode projects didn't complain, but Android's NDK did.
    Since RakWString defined an += operator, I added,
    Code (CSharp):
    1. const RakNet::RakWString RAK_DLL_EXPORT operator+(const RakNet::RakWString &lhs, const RakNet::RakWString &rhs)
    2. {
    3.     RakNet::RakWString str = RakNet::RakWString(lhs);
    4.     str += rhs;
    5.     return str;
    6. }
    to RakWString.cpp in my Android Project. Absolutely no idea if this is safe, but I didn't catch RakWString's + operator being used anywhere (though it clearly is). So I'm not sure if this is a good idea.

    Unless I'm mistaken, that's what Assets/Plugins/RakNet.bundle is. The catch is I can't seem to extract anything from his version, but it works.
     
    Last edited: Apr 8, 2017
  41. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I can definitely say that it's not an issue with the checkboxes getting unchecked. It was working on my end as well, I was never able to reproduce it -- From what I could gather listening to player feedback, the issue was only occurring for a certain percentage of players, but seemed to be occurring consistently for those players. There were no changes in my own multiplayer code when I upgraded to 1.51. Reverting to the previous version immediately fixed the issue for those having it, so there was definitely something introduced in 1.51 that is causing the issue.

    When I get around to it, I'll see if I can round up a person or two who was having the issue and get a better output log from them. In the meantime I'm curious if the pre-1.5.1 version will work ok with Unity 5.6, since I've been considering upgrading from 5.5?
     
  42. brend0r

    brend0r

    Joined:
    Mar 27, 2017
    Posts:
    5
    @FlyingHighUp About the OSX .bundle file - sorry, I totally missed it. Will try if it links.
    About the linux version - there are several ways to end up with undefined symbols and I'm not sure which one you took. Can you try to recompile the linux version and check if the symbol was exported? Also, you should not need to put the export macro in the function definition (usually in the cpp file) - it should be sufficient to put it in the function declaration (h or hpp file). The problem here is not that the function was not exported (it was, otherwise we wouldn't see it in the objdump), but that the declaration for it was not compiled and linked into the final library.
     
  43. Plumpman

    Plumpman

    Joined:
    Sep 7, 2012
    Posts:
    27
    This might sound like a silly question.

    Use Relay and Use Unity Matchmaking are set to false in the example NetworkManager.
    I'm trying to pass in the hosts public IP and GUID to connect directly in the StartClientAll.

    This seems to work, but I get the "replaceConnection" error stack and nothing happens.
    If I use the default Unity Matchmaking set to true and the original StartClientAll, it works totally fine.

    Am I going about this the wrong way if I want to direct connect to an IP?
     
  44. brend0r

    brend0r

    Joined:
    Mar 27, 2017
    Posts:
    5
    @FlyingHighUp any news regarding the Linux version of RakNetSwig? By the way, OSX one links just fine, so it's just the Linux one missing for us. If you have trouble getting it work, maybe you could put the project (just the RakNetSwig - the one your library is supposed to link to) somewhere and I will build it myself.
     
  45. dragonslaya84

    dragonslaya84

    Joined:
    Aug 10, 2014
    Posts:
    4
    Hello. Im trying to setup steam lobbies to unet like in the faq.

    At it's heart matchmaking is really simple. You just need some way to store each host's connection data and some way for the clients to get the data so they can connect. Steam lobbies are a popular choice but it's also fairly easy to roll your own system with something like php and mysql. Here's an example with steam lobbies:

    // Do this on the host in OnCreateMatch() after creating the steam lobby
    SteamMatchmaking.SetLobbyData(steamIDLobby, "matchID", createMatchResponse.networkId);
    SteamMatchmaking.SetLobbyData(steamIDLobby, "guid", natHelper.guid.ToString());
    SteamMatchmaking.SetLobbyData(steamIDLobby, "publicIP", externalIP);
    SteamMatchmaking.SetLobbyData(steamIDLobby, "internalIP", internalIP);

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

    But I have tried to get the internalip through different methods and they all come out null. I was wondering if anyone could point me in right direction.
     
  46. FlyingHighUp

    FlyingHighUp

    Joined:
    Apr 23, 2012
    Posts:
    16
    @brendor
    Sometimes I got away with removing the line all together, so a bit of my suspicion is that thegreatzebadiah might have commented it out for causing compilation errors.
    Or maybe you're right- RakWString looks like it's related to windows, so that method might have not have been included in the linux build at all.

    Yeah sorry man. I'm a full time student, and this week and next I'm still busy working on final projects and exams. (Also just in case there was a misunderstanding, I'm not one of the owners of the package haha)

    That being said, to create your own RakNetSwig.dll:
    Create a new C# Class Library In Visual Studio called RakNetSwig.
    - Make sure it targets .net 3.5 in the project settings. (This is what Unity supports)
    - Take all the .cs files I have here: https://drive.google.com/open?id=0B7cKeCSpjuApWlU3dnZnb2VrM1k
    and paste them into your project. Build, and then take RakNetSwig.dll.
    You should be able to take your old RakNetSwig.dll, replace it with this and have no issues.

    If you want to start everything from scratch (including generating the .cs files), follow the HowToBuild.txt I have in Sources/ here https://drive.google.com/open?id=0B7cKeCSpjuApRVNaalBuMGFvT1U
    It offers a tutorial on how to build RakNet for macOS,iOS, and Android. But no linux - so you'd have to improvise there :(.

    Long story short: To build for linux, all you'd need to do is to copy over RakNet_wrap.cxx and RakNet_wrap.h into your Raknet Sources folder. (You can find these under /CplusDLLIncludes in my first download link) Then build a Raknet.so with that.
     
    Last edited: Apr 14, 2017
  47. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Can you get me that error? Maybe I can figure out what's going wrong. You should be able to pass in internalIP, externalIP, and guid to StartClientAll() and be good to go so it sounds like something isn't right somewhere.
     
  48. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @FlyingHighUp @brend0r If I ever get around to actually fixing this issue it looks like you guys have compiled a ton of useful info for me here. Thanks. Hopefully I can get to the bottom of it soon.

    Oh boy does this sound embarrassingly likely.
     
  49. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    NetworkPlayer.ipAddress doesn't work? That's what I usually use.
     
  50. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Doghelmer Maybe your issues are related to the way I changed handling of match size / max connections. I fixed an off-by-one error with maxConnections that was allowing more players to connect than should have been allowed. Maybe you were working around the previous broken code and now that it's fixed it's throwing something off? Just a thought. There was a lot changed in that update so it's hard to nail down.