Hey guys, I recently posted this in the networking forum, but I figured (and i know, I’m a sinner) I’d spam support before i went directly to the unity guys and begged for help with an open wallet. I’m pretty desperate here. we’ve got a release on the 12th and I feel like the shit has more or less hit the fan.
it would seem that I can’t connect to network games built in unity 3 (the one’s I’ve checked, anyway). the master server provided by unity works great, as far as i can tell. if my friends start a game, i can detect it, I just can’t connect. (same goes with i try and start one and they try)
I can connect to games made in earlier versions of unity. IN FACT, I had my game working 100% of the time in unity 2.6. as soon as i switched over to unity 3 (I had to, unfortunately) everything stopped working. Even the unity networking example (which worked when compiled in 2.6) doesn’t work for me now that I have 3… so I’m confident it isn’t a problem with my code. (not that i’m trying to avoid responsibility… I’ll do everything and anything I can)
I am behind a router, and apparently my NAT capabilities are iffy. It sounds like this issue could be fixed with properly setting up some port forwarding but I have no interest in making average users screw with a such a technical nightmare to try a game that they have no reason to put in the work for.
Any ideas here? What exactly changed in 3? is there something that I can do? any general advice? I understand that connectivity is an iffy topic to begin with, and there are a lot of people on private networks that simply won’t be able to connect with anyone, but if I can’t connect using my simple home network, then as far as i can tell, I’m totally screwed; I can’t imagine that many other people will be able to play, either.
Basically what changed was that RakNet was upgraded to the latest version (at the time), 3.732. This included an update to how NAT punchthrough functionality. However, it should still work of course. Right now there is a known issue where the NAT punchthrough will likely only work one time in an Editor session (the first time). It can be worked around by setting the deprecated Network.useNat=true property before initializing the server. Standalones and webplayers should be unaffected. Are you testing on both sides with those? If you are and you still think it’s broken set the network logging level to Full in your project, do a test run and use the bug reporter to send the log files along with a bug report. Attach the project you are using if you can. Send me the case number and I’ll have a look at it.
I’ll fill out a bug report asap… and attach all my stuff, although It’s nothing much. here’s a quick update:
I’m pretty much using the sample networking project, with a few small changes to avoid all of the warnings I get when I compile.
My computer is now also plugged directly into my cable modem so there shouldn’t even be a need for NAT punchthrough at all. connection with others now works because of this, but it’s not really a feasible solution and for some reason my connection tester continually returns
ConnectionTesterStatus.PublicIPNoServerStarted:
testMessage = "Public IP address but server not initialized, "+
"it must be started to check server accessibility. Restart "+
“connection test when ready.”;
and then re-attempts to run the test for ever. this scares me because it’s sort of confusing behavior and I’m curious about weather or not it implies a solution to my other problem. So far, I haven’t found a single person behind a router that has been able to connect to a server (or start one themselves), unless the server was started with a public IP. Maybe I’m just unlucky in selecting my test pool:)
at any rate, I’ll submit a bug report soon and send you a note.
I too am seeing something fishy going on with the NAT punchthrough. I have a case where I have one full cone NAT and one address restricted NAT, and both running an app in the standalone player. Only if the full cone hosts can I connect with NAT punchthrough. If the address restricted hosts I get a failure to connect. This shouldn’t be happening based on the NAT types, but even weirder is that according to Kevin at Raknet the behavior should be identical regardless of who hosts.
ah… well i’m sad/happy to hear i’m not the only one with problems.
I’m currently trying to set up port forwarding to get things to work for me… after that it’ll be onto getting paid hosting for a proxy server. it’s a cold day in hell
Okay, so this is a bit of a guess since I have come into Unity with only the 3.0 references available to me (but with an inherited 2.xx project), but I think that what we may be running into is a change in the way the Unity API works in terms of enabling NAT punchthrough. From what I can tell, the old 2.xx stuff would attempt NAT punchthrough with given a server IP/port list if Network.useNAT was set. It also appears, and this one bit me, that if you use the same basic scripts ported to the new 3.xx code, Unity will NOT attempt NAT punchthrough even if the host has set NAT to true when Initializing the server. In order to get NAT punchthrough working you have to connect to the GUID. I am not 100% sure if this is new/changed behavior or what, but converting my old scripts to use the guid version of Network.Connect seemed to fix my issue. If someone from Unity who knows what the story is wants to confirm/deny, that would be most appreciated.
I’m still new to Unity Networking, but I’ll throw in my two cents - perhaps it will help somehow. In general my Networking works, even through routers/ NAT. However, I sometimes get weird behavior in that I can’t connect to a certain user (behind the same router!), but when I host they can connect to me without a problem (and/ or vice versa). The conditions are nearly identical as well: 2 MacBook Pro’s using the exact same build, both behind the same modem + router and in the same internal IP range. I’m using this simple code from the documentation to determine whether or not to use NAT punchthrough:
I’ve also had some weird problems when I called the MasterServer connection twice or more in the same function (i.e. Network.InitializeServer() and Network.RequestHostList()).
Hope this helps somehow and best of luck getting it to work in time!
wow, i dont know how I missed those last two responses… thanks guys…
fantastic, two new things for me to try! many many thanks!
stubborngorilla, that’s some weird stuff man. I dig that the old Network.useNat was depreciated, but I assumed that the new boolean argument in the InitializeServer function was enough.
I’m going to try connecting to the GUID first thing tomorrow morning!
Mex and anyone else hitting this issue, the basic idea is you need to pull and use the guid from the host data returned by the MasterServer. Something like this:
var hostData: HostData[ ] = MasterServer.PollHostList();
for (var i:int=0; i<hostData.length; i++) {
// blah blah, get interesting game list data
// now make sure I grab this too
serverList[guid] = hostData*.guid;* }[/INDENT] Then, when you go to connect, use it instead of the ip and port: Network.Connect(hostData[whoeverGotChosen].guid);