Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

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

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

  1. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
    @thegreatzebadiah Thanks for looking into it for me! :) It's ok if it gets pushed back to next wave of updates. We do hope to deploy to the Xbox One when release day comes for our game so compatibility with the Windows Store would be truely awesome!
     
    thegreatzebadiah likes this.
  2. TubooBokBok

    TubooBokBok

    Joined:
    Mar 2, 2014
    Posts:
    30
    Hi,

    I am receiving the following error when a client attempts to connect to a host:

    Code (CSharp):
    1. Unknown message ID 32763 connId:1
    2. UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
    I am using unity 5.5.0f3 with the latest version of your asset.
    In my network manager I have unchecked connect relay and use unity matchmaking

    I am trying to make connections without any sort of matchmaking. Instead I am passing all needed info into this method:
    Code (CSharp):
    1.     public void ConnectToServer() {
    2.  
    3.         string input = connectField.text;
    4.  
    5.         string[] splitText = input.Split('^');
    6.         ulong newGuid = (ulong)long.Parse(splitText[2]);
    7.  
    8.         StartClientAll(splitText[0], splitText[1], newGuid, 0, splitText[3], splitText[4], null, null, 0, 0, false);
    9.     }
    Let me know if you need any additional information, and thank you for your help!
     
  3. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
    @thegreatzebadiah Hey! So I had a chance to try out the new MigrationManager. I have some good news and some bad news.

    Migration Bug:
    The bad news is the bug is still there where the player doesn't get reassigned to his player object after so many migrations (occurs at 3 migrations for one person and 4 migrations for both of them). In order to test this I always make sure the players are moved to different positions or else I only ever see one and it looks like it is working correctly. I did have one case where it seemed like it worked more than four times but only for one player. Here are the error messages printed off.

    host id out of bound id {0} no host exists
    UnityEngine.Networking.NetworkClient:Shutdown()
    NATTraversal.NetworkManager:StopClient() (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:589)
    NATTraversal.NetworkManager:StopHost() (at E:/_Noble Whale/NAT Traversal Stuff/NAT Traversal DLL/NATTraversalForUNET/NetworkManager.cs:629)
    ExampleNetworkManager:OnGUI() (at Assets/NAT Traversal Example/ExampleNetworkManager.cs:143)

    and

    OnReconnectMessage connId=0 player null for netId:2 msg.playerControllerId:0
    UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()

    New Migration Bug:
    I do not know how to reproduce this bug as it doesn't happen very often. I maybe had it happen to me twice in the last three hours of testing the new package you sent me. What happens is the host that disconnects will be given the option to "reconnect to new host" like it should, but the client is given the option to "connect to new host" when they should be given the option to "start as host." This is a problem as a new host is never created. For all I know this bug is created from the previous migration bug. I just thought I would make you aware of it.

    Bug That I Managed To Fix:
    I found that when migrating hosts, if I left the match completely, I was unable to join that match I left as if the match had been destroyed. Luckily that was not the case. I found that there is code stopping you from joining an old match in the ExampleNetworkManager. This is not much of an issue if the game is popular and there are hundreds of active matches. However, if a game is not very popular, it would pose a problem if a player left a match and then was not able to find another match because the only active match was the one they just left. Therefore, I added in some code that checks to make sure you weren't the only person in the match you just left. If you were the host and you had clients, we just assume a successful host migration takes place and the match is still joinable. If you are the client and you leave, we just assume that the host is still hosting that match and it is still joinable. An issue may arise if the host migration has not yet taken place and you attempt to join or there wasn't ever a successful migration and the match was just dropped. To fix this (which I haven't done yet), I will just make the match unjoinable until there is a new host, and if a new host is never found, I will just destroy the match. Therefore, players will never be able to join a match that doesn't have a host and people can still rejoin matches they left. I will send the project to you with this fix. If you don't want to use it that is fine. I just thought others might want it as well.
     
  4. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    84
  5. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @Eiseno I've never done anything with voice chat so I'm not sure how much help I can be. You mention in the linked post that your problem is that "OnProxySpawned" isn't being called, but I don't see that method in any of the code you posted.

    @TCROC I'm about 99% positive I just sent you the wrong thing. Let me confirm real quick and then I should have something new for you.
     
  6. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @TubooBokBok It looks to me like maybe you're overriding OnServerConnect() but not calling the base method. Just add a call to base.OnServerConnect() and you should be good to go.

    @TCROC Yeah...I just changed my build process a bit and I totally missed the important step of actually replacing the dll. I just sent you a new copy that should actually be updated.
     
  7. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    84
    Sorry i forget OnProxyRequested

    https://github.com/alkamegames/unit...t/Scripts/Networking/VoiceChatNetworkProxy.cs
     
  8. T0T0S

    T0T0S

    Joined:
    Nov 30, 2015
    Posts:
    3
    Hello there, just a quick question, I can't connect to the facilitator you are hosting on your site (thx by the way) since this morning.

    Is everything alright on your end ?
    Did I miss something?
    Thank you.

     
  9. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @T0T0S It was just down for a bit for routine maintenance. It's back up now. Just a reminder though that the Facilitator we host is only for testing and should not be used in a released game. You'll need to host your own if you don't want it to randomly go down whenever our server sneezes.
     
  10. T0T0S

    T0T0S

    Joined:
    Nov 30, 2015
    Posts:
    3
    Sure thing, thx :)
     
  11. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
    @thegreatzebadiah I just got done testing out the new build you sent me and the host migration works perfectly! :)
     
    thegreatzebadiah likes this.
  12. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    241
    @thegreatzebadiah i tested out the build you sent me, and it hasn't really solved my connection issues unfortunately. looking over things a little closer, it seems to timeout when connecting to particular players. currently, my problem is an IPv6 client connecting to an IPv4 host. i'm not totally sure that it's a 4/6 issue though - i have been able to make this type of connection with one friend repeatedly. but with two other friends, i've had no luck. they are able to connect to me no problem, so maybe it's trouble with port forwarding.

    i know punchthrough isn't going to work in some instances, but so far, my success rate is maybe 60%. so, some stupid questions to verify i have things set up right -

    1. basically, i'm emulating the setup in the Example scene. Does this handle portforwarding automatically? i see that there's also the ExampleNATHelperOnly scene that I just started looking at. I see that the NATHelperTester class has a bunch of code for running port mapping & such....wondering if i actually need to emulate this, or if just going along with the Example scene should be good enough.

    2. from the README, i see "Both **upnp** and **nat pmp** are supported"...does this stuff automatically happen without any additional configuration on my part?

    3. also from the README, "NAT punch-through works more often if you have at least two public IPs on the server your Facilitator is running on."...what does this mean exactly? i have my facilitator running on an aws instance. is there anything i should be setting up there to improve my success rate?

    4. i can try having one of my friends set up port forwarding on his router to see if it would make any difference at all...but what port should i have him open up? the facilicator port (61111)?
     
    deliinteractive likes this.
  13. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    1. The Example scene is the one you want, it does everything including port forwarding. The ExampleNATHelperOnly scene is to demonstrate how you would implement punch-through for something other than UNet. You don't have to worry about manually doing all the things in NATHelperTester because they are being done for you automatically.

    2. Yes, as long as you have port forwarding checkbox enabled on the NATHelper component.

    3. I'm honestly not that clear on it myself..I'm mostly just repeating what the RakNet documentation says. I'm not sure how you would configure a second IP on AWS but I suspect it ain't free.

    4. You could have him forward whatever you have set for the networkPort on the NetworkManager (7777 by default). This should allow you to connect directly every time. If it does not then I have really screwed something up. Unfortunately you can't manually forward the punch-through port because it is random every time. You could forward the facilitator port but I don't think it's necessary or helpful. The Facilitator never initiates a connection to a client so it shouldn't need port forwarding.

    I'm not sure why your success rate is so low. Maybe you're just really unlucky :). More likely it's somehow related to ipv6. You can also have your friends check the NAT settings in their router. If it's anything like "symmetric" that's probably the source of the problem.
     
  14. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
    @Eiseno @thegreatzebadiah I just got done integrating voice chat with NAT Traversal! It is pretty late for me right now so I will put together a small example project and upload it to this forum for people to check out tomorrow. I will not include the NAT Traversal asset inside the project. The only things that will be included will be the scripts and the voice chat asset. You will have to import NAT Traversal separately.

    Here's the link if anyone wants to check out where I got the voice chat asset. (Credit to @Eiseno for discovering the asset).
    https://github.com/alkamegames/unityassets
     
    thegreatzebadiah likes this.
  15. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    84
    Hi @TCROC
    Thanks.If you share sample project it will be really good.I spend 1 week and cant figure anything :)
     
  16. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
    @Eiseno @thegreatzebadiah Here is the example project of NAT Traversal compatibility with voice chat. This project does not contain the NAT Traversal asset. You will have to import NAT Traversal separately. It only contains scripts that work with NAT Traversal and the voice chat asset. I hope this comes of good use to people :)
    https://drive.google.com/file/d/0B6F8g8piEivTOVlQdlotclZIM00/view?usp=sharing

    Here's the link if anyone wants to check out where I got the voice chat asset. (Credit to @Eiseno for discovering the asset).
    https://github.com/alkamegames/unityassets
     
    Last edited: Jan 7, 2017
    robochase and thegreatzebadiah like this.
  17. sammyben

    sammyben

    Joined:
    Nov 12, 2013
    Posts:
    7
    Hi there,
    Looking at making a lockstep multiplayer rts game in unity, so unfortunately looks like I will be having Unity's low level api for multiplayer. Any chance you could make your plugin work with this?
     
  18. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    241
    I'm interested in knowing the answer myself :)

    But I don't see why you'd HAVE TO use the low level api to make a lockstep rts. you're still just sending messages around to players, business as usual? the HLAPI does give you a lot of flexibility for this kind of stuff
     
  19. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    84
    @thegreatzebadiah did u find a change to look lobby system ?
     
  20. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    84
    Thanks for adding lobbymanager with new update i cant find how to use it.Do u have any example ?
     
  21. deliinteractive

    deliinteractive

    Joined:
    Oct 8, 2014
    Posts:
    25
    Howdy once again!

    Alrighty, so we picked up the NATTraversal update which just hit the asset store, but still have no success with IPv6 support. I'm attaching a picture of the log from an attempt to join the dev on my team with an IPv6 address, all in the Example scene with no changes to the example network manager on either of our ends. The log begins after I connected to the facilitator and hit join on his match:


    Needless to say we still don't have IPv6 support with our custom network manager in our game. We even enabled the relay and got that up and running in the hope of getting better IPv6 support, but still no luck. Please let me know if you need any additional help or info in testing this out. We are supposed to release to Steam early access February 8th, so time is getting slim for us. Thanks as always, though, for keeping the plugin up to date and constantly pushing fixes!
     
  22. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    241
    that pretty much matches my callstack too. if you turn your network manager to 'developer' logging, there's more info that only shows up in the editor.log...things like it failing to connect after 10 attempts.

    what are your test cases? here's what i've tested so far:

    IPv6 client connecting to IPv4 host = timeout. i've only been able to test this with two different people who match this configuration, so not a large sample size :/
    IPv6 client connecting to IPv6 host = success (only been able to test this with one friend, but it works every time)
    IPv4 client connecting to IPv6 host = success (tested with numerous people)
    IPv4 client connecting to IPv4 host = ???? (haven't been able to test this one yet because i'm on IPv6 personally. i assume it probably works though??)

    also, what are you using for your timeouts? i bumped everything up to 30 seconds and it hasn't really helped
     
    Last edited: Jan 11, 2017
  23. deliinteractive

    deliinteractive

    Joined:
    Oct 8, 2014
    Posts:
    25
    We currently only have one developer who always carries an IPv6 address, so the test cases I can present to you are even slimmer. However, I believe I've had different results than you in general, so I'll post the trends I see in the order you have them:

    -IPv6 client connecting to IPv4 host = Success. Our IPv6 dev almost always successfully connects to our IPv4 devs, and IPv4 beta testers.
    -IPv6 client connecting to IPv6 host = Failure. I only have one test case of this, but I did not see this work after multiple attempts. With that said, this test was prior to the most recent two updates to NATTraversal. They could very well be fixed now.
    -IPv4 client connecting to IPv6 host = Failure. This is more consistent, and some of our beta testers who we *suspect* have IPv6 addresses (still trying to confirm with them) cannot have any clients join them when they host. *EDIT: Confirmed, at least one has a public IPv6 address who has been unable to get other players to join his hosted games.
    -IPv4 client connecting to IPv4 host = Success. It's very rare that I see this fail. Works exactly as advertised on the first page of this forum thread, awesome success rates.

    It's interesting that we have such different results! Perhaps Zeb is right and certain people we test with frequently have symmetric NAT or some other barrier. I want to say that the problem is more systemic, though, due to the results of some of our beta testers. I will continue to farm as much data from them as I can. The heuristic I've arrived at with regards to NATTraversal success is: IPv4 host = good, IPv6 host = bad.

    As far as timeouts, I've got 10 seconds across the board: direct connection, punchthrough, and port forwarding.
     
    Last edited: Jan 14, 2017
  24. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
    Hey @Eiseno. I believe NAT Traversal is compatible with UNET stuff so you should be able apply it to Unity's example Lobby system. Here is the link. The example project is at the bottom of the page. I haven't tried it out myself yet but it should work.

    https://docs.unity3d.com/Manual/UNetLobby.html
     
    thegreatzebadiah likes this.
  25. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    84
    I change my lobbymanager with natlobbymanager it started giving errors.
     
  26. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
    @Eiseno I haven't tried it yet, but what I would recommend doing is seeing how Unity implements their script, replace it with NAT Traversal's script, and see how that works. I will be messing with it myself here soon too.
     
  27. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
  28. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
    @thegreatzebadiah this website may contain the solution. It talks about the differences between .NET 3.5 and .NET Core with plugins and Unity and how to fix them
     
  29. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I'm getting an error right now that occurs when I join a host's game as a client, quit that game, and then rejoin the game again. The host is logged in for the entire time and is basically not doing anything -- no scene changes or anything like that -- only the client is taking any action. The error stack looks like this:

    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. NATTraversal.NetworkManager.replaceConnection (UnityEngine.Networking.NetworkConnection oldConn, UnityEngine.Networking.NetworkConnection newConn)
    4. NATTraversal.NetworkManager.OnMultiClientConnect (UnityEngine.Networking.NetworkConnection conn)
    5. NATTraversal.NetworkManager.OnMultiClientConnectInternal (UnityEngine.Networking.NetworkConnection conn)
    6. NATTraversal.NetworkManager.OnMultiClientConnectMsg (UnityEngine.Networking.NetworkMessage netMsg)
    7. UnityEngine.Networking.NetworkConnection.InvokeHandler (Int16 msgType,
    8. UnityEngine.Networking.NetworkReader reader, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:217)
    9. UnityEngine.Networking.NetworkConnection.InvokeHandlerNoData (Int16 msgType) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:199)
    10. UnityEngine.Networking.NetworkClient.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:718)
    11. UnityEngine.Networking.NetworkClient.UpdateClients () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:950)
    12. UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:1073)
    13.  
    When the client leaves the game, I'm using StopClient(), but I suspect that there is more I need to do in order to properly remove them from the game. Is there anything that I'm missing here?

    Also of note, this only occurs when I'm using NatTraversal, and not the normal Unity matchmaking.

    @Jos-Yule I just noticed that you had posted a similar stack a few pages ago. Were you ever able to resolve this?

    EDIT:
    I found a solution, which was just to destroy the entire object after ending the game and then create a new one. Not extremely elegant though, I'm still curious what the "correct" way to go about doing this would be.
     
    Last edited: Jan 14, 2017
  30. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    150
  31. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    84
    When i listing game
    1- How can i get current map name ?
    2-Is it possible to add additional properties to game and show it when listing the game.For example i want to add game mode property and show it when listing game.
     
  32. deliinteractive

    deliinteractive

    Joined:
    Oct 8, 2014
    Posts:
    25
    We found that we had to delete our network manager as well for better error resolution after a game ends. This is also after running NetworkServer.SetAllClientsNotReady(), and even then we still have some funky prefabs sitting around in our project which get impacted after leaving our game scene, so our standalone application actually has to restart in its entirety to prevent hosts from running around with messed up prefabs (and thus causing desync). I will say however, that the strange prefab adjustments don't appear to be a NATTraversal problem, and appear to still show up if we use the regular implementation of UNet. Maybe something project specific - we haven't been able to track it down yet, except to the commonality between affected prefabs that they are allowed to have local client authority (but are not players).
    *edit*: The weird prefabs problem was being caused by bad sceneIds placed on two objects in our scene.
     
    Last edited: Jan 15, 2017
  33. R1PFake

    R1PFake

    Joined:
    Aug 7, 2015
    Posts:
    507
    I have a total noob question but what's the bonus to use this pack with the steam matchmaking? Do i still need
    The Facilitator if i have access to steam matchmaking? We want to make a simple turn based game, so we only have to send a few messages/rpc about the player turn informations and not a real time action game, we already have a prototype with UNET but we want more then 20 CCU for the release game and the direct connect feature of this pack seems promising. We have access to the steam matchmaking but tbh this is our first network game and we only used the pure UNET to learn what we need and didn't touch anything of the steam api yet.
     
  34. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I'm having an issue running the Facilitator on an Amazon EC2 instance that I recently set up. Following some of the instructions posted earlier here, I started a Linux instance ("Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type"), uploaded the Facilitator file to the /home/ec2-user directory, and ran the following commands through Putty:

    chmod u+x Facilitator
    ./Facilitator

    I received the message:
    ./Facilitator: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./Facilitator)

    Any ideas on how to proceed?

    -------------------------------------------------------------------
    ALTERNATIVELY:

    I got a Windows-based Amazon EC2 instance running (Microsoft Windows Server 2016 Base with Containers), and started running Facilitator.exe on it. I see the following (minus the xx's of course)

    IPs:
    1. 172.xx.xx.1
    2. 172.xx.xx.16
    Using port 61111
    Started on 172.xx.xx.1|61111

    I don't recognize the first number, the second appears to be the private IP address of the server.

    I've attempted to use both of these in the "Facilitator IP" field of NAT Helper (also the "public ip address", I really don't know what I'm doing), but I'm consistently getting "Failed to Connect" warnings. I've been able to connect when grabblesgame.com is in that field. Also, I did follow the Security Group instructions in the FAQ. I also tried running a different type of Windows server, "Microsoft Windows Server 2016 Base", with similar results -- except I only received 1 IP address instead of 2.

    Is there something I'm missing here?
     
    Last edited: Jan 15, 2017
  35. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    241
    @R1PFake you need the facilitator if you intend to use this plugin, regardless of whether you choose to use unity's matchmaker or steam's matchmaker. what this plugin allows is for players to connect to each other without using unity's RELAY server (sort of a middle man server between the host and the client). this plugin accomplishes this by running the facilitator app on a separate server - all players in the game talk to the facilitator during setup in an attempt to set up nat punchthrough. in a nutshell.

    the stuff a matchmaker does happens before the faciliator stuff. basically the matchmaker is a server that lets some players notify other players that they're hosting a game and -this- is the IP address that they'll find the game at. once other players get the host's ip address, it kind of falls on the facilitator to connect the two players.
     
  36. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    241
    @Doghelmer i had this same linux problem on AWS last week actually. i followed the instructions on the top answer here to fix - http://askubuntu.com/questions/575505/glibcxx-3-4-20-not-found-how-to-fix-this-error

    basically -
    Code (CSharp):
    1. sudo apt-get install libstdc++6
    2. sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    3. sudo apt-get update
    4. sudo apt-get upgrade
    5. sudo apt-get dist-upgrade
     
  37. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    I seem to be getting "apt-get: command not found" when I run these. What type of Linux server were you using?

    Still hoping to get the Windows version working, since I seem to be further along with that. Am I supposed to be using those IPs that it spits out (from my last post) in my "Facilitator IP" field? Is there some other piece of information that I need to be adding somewhere, aside from "Facilitator Port"?
     
  38. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    241
    whoops sorry. i set up the aws quite a while ago and forgot what i picked...looks like Ubuntu 14.04.5 here. i'm guessing installing on your linux server is going to be...kind of similar? figure out what you need to install and install it, basically (apt-get is just some handy package installer i believe...). google might be able to help you find better instructions for installing the thing you're missing for your OS
     
  39. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    OK, I finally got a Facilitator set up on an Amazon EC2 server. This took a lot longer for me to figure out than it probably should have, so here's a quick-and-dirty list of steps I took using a Windows machine.

    - Create an AWS Account here: https://console.aws.amazon.com/ec2/
    - From your Dashboard, choose to Launch Instance.
    - Choose Ubuntu Server 14.04 LTS (HVM), SSD Volume Type and wait for it to finish Initializing.
    - Follow the FAQ to change the new server's security settings.
    - Using FileZilla, upload the "Facilitator" file (no extension) included with the plugin. Here's some instructions on getting it uploaded. It should go in the /home/ubuntu directory.
    - Get Putty and connect to the server using these instructions.
    - On Putty, type the following series of commands:
    Code (csharp):
    1. sudo apt-get install libstdc++6
    2. sudo add-apt-repository ppa:ubuntu-toolchain-r/test
    3. sudo apt-get update
    4. sudo apt-get upgrade
    5. sudo apt-get dist-upgrade
    6. chmod u+x Facilitator
    - Since Putty ends your session when you quit the program, you'll want to use something called Screen to create a second "window" (which does not actually appear in a second physical window on your desktop). To do this, use the commands:
    Code (csharp):
    1. screen (starts the program)
    2. "ctrl+a" and then "c" (creates a new window)
    3. ./Facilitator (starts the Facilitator)
    4. "ctrl+a" and then "n" (switch to the previous window)
    Now you can quit out of Putty, and the Facilitator will keep running.
    - In Unity, your NatHelper's Facilitator IP should be the "Public IP" that you see in the description when you click on your server instance in AWS. Facilitator Port should be 61111.

    And there ya go.
     
    thegreatzebadiah and robochase like this.
  40. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    @thegreatzebadiah I think I may have found a bug with NatHelper's Facilitator Time Out. It appears that the timeout is starting from the time that the NatHelper is awoken, rather than from the time the I call StartHostAll or StartClientAll. So if I set it to 10 and attempt to start a host or client after being in my scene for at least 10 seconds, I'll consistently get a timeout.

    Unless I'm just using the plugin wrong in some way shape or form :p

    As a workaround, right before I use StartHostAll or StartClientAll, I destroy NatHelper and immediately add a new one. I've been able to connect to the facilitator very consistently this way.

    Not sure about the other timeouts in NatHelper.
     
    Last edited: Jan 17, 2017
  41. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    You guys sure do keep me busy :)
     
  42. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    This is (almost) correct, the facilitator connection is started in NetworkManager.Start(), before any calls to StartHostAll() or StartClientAll().

    Definitely seems odd and doesn't happen to me in the Example scene.

    The way it's supposed to work is that the Facilitator connection is established as soon as possible so that there's no waiting when StartHostAll() or StartClientAll() is called. That being said, there very well could be something going wrong. I would confirm that it's not happening the example scene (maybe I just tested wrong somehow). If you can recreate it in the Example scene let me know how and I should be able to track it down. If not it would help if you could send me a small project that I can use to recreate the issue.
     
  43. Doghelmer

    Doghelmer

    Joined:
    Aug 30, 2014
    Posts:
    120
    Yeah, it's totally possible that I'm doing something or other to cause this. The only unusual thing I can think of off the top of my head is that I'm instantiating the NetworkManager's object very slightly after starting the scene. Other than that, I didn't mess around with the NatHelper at all. I'll check into it a bit more when I get some time.
     
  44. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    Thanks for this awesome write-up. I'm going to add this to the FAQ.
     
  45. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    You can include this info in the match name. That's how I pass all the connection info around. It's a bit of a crappy work around to include "meta data" in the match info but I don't believe there's any other way.
     
    booferei likes this.
  46. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    It should be enough to call StopClient() but make sure you are calling it on an instance of NATTraversal.NetworkManager and not UnityEngine.Networking.NetworkManager. So for example if you are calling
    Code (CSharp):
    1. NetworkManager.singleton.StopClient()
    it should instead be
    Code (CSharp):
    1. ((NATTraversal.NetworkManager)NetworkManager.singleton).StopClient()
     
  47. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    The new NATLobbyManager is a bit experimental at the moment. It is basically a one for one copy of unity's NetworkLobbyManager though with just a few changes to get it working with the plugin. What kind of errors are you seeing? Can you get me a stack trace? Also, I included all of the code for NATLobbyManager and NATLobbyPlayer in the plugin folder so the code is all there to see which should help with debugging.
    It should work exactly the same as Unity's NetworkLobbyManager so if you can find a tutorial / examples for that they should apply.
     
  48. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    The plugin works just fine with the low level api. There's is an example scene included, ExampleNATHelperOnly, that shows how to use the punchthrough with any networking system you want. Basically once the hole is punched you can use whatever you want to connect.
     
  49. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    @deliinteractive @robochase

    I'm going to go ahead and admit that I have no clue what I'm doing with this ipv6 stuff. I'm just going to explain my thought process as best I can and post the relevant code here and hope someone smarter than me can help figure out what obvious thing I'm doing wrong.

    First things first, I'm getting both a 'local' and external IPv6, but I'm really not sure the local one is necessary or meaningful in any way because the whole point of IPv6 is that every computer is directly routable right? Why would an internal IPv6 ever be needed... For reference here is how I get the local IPv6:

    Code (CSharp):
    1.  
    2.         public string getLocalIPv6()
    3.         {
    4.             try
    5.             {
    6.                 foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces())
    7.                 {
    8.                     if (item.OperationalStatus == OperationalStatus.Up)
    9.                     {
    10.                         foreach (UnicastIPAddressInformation ip in item.GetIPProperties().UnicastAddresses)
    11.                         {
    12.                             if (ip.Address.AddressFamily == AddressFamily.InterNetworkV6)
    13.                             {
    14.                                 return ip.Address.ToString();
    15.                             }
    16.                         }
    17.                     }
    18.                 }
    19.             }
    20.             catch(Exception e)
    21.             {
    22.                 return "";
    23.             }
    24.  
    25.             return "";
    26.         }
    27.  
    The external IPv6 is obtained by querying http://ipv6.icanhazip.com

    I then start the host in the normal way, calling base.StartHost() on the NetworkManager. Is there something special I should be doing here to enable IPv6 hosting? Seems like no since you guys have at least reported one successful connection to an IPv6 host.

    On the clients end all of the connection info is obtained as usual from the match name, including both ipv6 addresses. All the IP's are then passed into this method that tries to determine which one to use to connect:

    Code (CSharp):
    1.  
    2.         virtual public string pickCorrectAddressToConnectTo(string hostExternalIP, string hostInternalIP, string hostExternalIPv6, string hostInternalIPv6)
    3.         {
    4.             // If we have an external IPv4 address and the host does too then we should be able to connect to the host via ipv4
    5.             if (!string.IsNullOrEmpty(externalIP) && !string.IsNullOrEmpty(hostExternalIP))
    6.             {
    7.                 if (hostExternalIP == externalIP && !string.IsNullOrEmpty(hostInternalIP)) // Client and host are behind the same router
    8.                 {
    9.                     if (hostInternalIP == Network.player.ipAddress) // Host is running on the same computer as client, two separate builds
    10.                     {
    11.                         if (LogFilter.logDebug) Debug.Log(TAG + "Using localhost address.");
    12.                         return "127.0.0.1";
    13.                     }
    14.                     else // Host is on the same local network as client
    15.                     {
    16.                         if (LogFilter.logDebug) Debug.Log(TAG + "Using host's local ip address.");
    17.                         return hostInternalIP;
    18.                     }
    19.                 }
    20.                 else // Host is somewhere out on the internet
    21.                 {
    22.                     if (LogFilter.logDebug) Debug.Log(TAG + "Using host's external ip address.");
    23.                     return hostExternalIP;
    24.                 }
    25.             }
    26.             // Fall back to ipv6 if necessary
    27.             else if (!string.IsNullOrEmpty(externalIPv6) && !string.IsNullOrEmpty(hostExternalIPv6))
    28.             {
    29.                 if (hostExternalIPv6 == externalIPv6 && !string.IsNullOrEmpty(hostInternalIPv6)) // Client and host are behind the same router
    30.                 {
    31.                     if (hostInternalIPv6 == getLocalIPv6()) // Client and host are on the same computer
    32.                     {
    33.                         if (LogFilter.logDebug) Debug.Log(TAG + "Using ipv6 localhost address.");
    34.                         return "::1";
    35.                     }
    36.                     else // Client and host are not the same computer
    37.                     {
    38.                         if (LogFilter.logDebug) Debug.Log(TAG + "Using host's local ipv6 address.");
    39.                         return hostInternalIPv6;
    40.                     }
    41.                 }
    42.                 else // Host is somewhere out on the internet
    43.                 {
    44.                     if (LogFilter.logDebug) Debug.Log(TAG + "Using host's external ipv6 address.");
    45.                     return hostExternalIPv6;
    46.                 }
    47.  
    48.             }
    49.             else
    50.             {
    51.                 if (externalIPv6 == "" && hostExternalIPv6 != "") Debug.LogError(TAG + "Host only supports ipv6 connections and client does not support ipv6.");
    52.                 else if (externalIP == "" && hostExternalIP != "") Debug.LogError(TAG + "Host only supports ipv4 connections and client does not support ipv4.");
    53.  
    54.                 return "";
    55.             }
    56.         }
    57.  
    This could very well be where it's all going wrong, but I'm not sure what the correct procedure would be.

    Once the ip is chosen I pass it into directClient.Connect(networkAddress, networkPort) to start the direct connection.

    That's pretty much it, sorry for the stream-of-consciousness brain dump but I'm pretty stuck and I don't have an IPv6 connection myself so it's hard to even test.

    One thing you guys could try is overriding the pickCorrectAddressToConnectTo() method and trying different ways of picking the address.
     
    Last edited: Jan 17, 2017
  50. robochase

    robochase

    Joined:
    Mar 1, 2014
    Posts:
    241
    @thegreatzebadiah thanks for the tip! i'll look at what that function is currently returning, and possibly try forcing it to return specific addresses to see if it helps.

    question about the getLocalIPv6 function though...is that supposed to be like the computer's local IP address on my LAN? because i'm pretty sure i have an IPv4 address on my LAN, but my external IP address (aka the router's actual IP address) is IPv6. just trying to rule out any weirdness that might happen if you treat the internal address similarly when in fact they shouldn't be...