I just spend a week updating my own network library to build on top of the new UNET. The only problem: how can I allow two users behind a NAT/Firewall/Router to connect to each other? It seems the new system doesn’t contain any nat traversal mechanism anymore?!?
Good question. They gave us relay server to avoid NAT issues, but it will introduce severe ping times (especially on fully authoritative games), concurrent connections limit, charges for usage, and message per second limitations.
From my point of view there’s no point creating a copy of Photon. I actually liked RakNet for NAT punch-through.
I’m trying to find info how to implement automatic port forwarding or NAT punching for the dedicated servers (so clients don’t need to deal with any routing issues, just connect to public IP).
If it works - then all you would need is a custom master server, which is dead easy to create using any tools and programming language. Yay I think we could get our raknet features back.
I just have tested it on 2 PCs with 2 different public IP addresses. One behind uPnP-enabled router (NAT), while other is directly connected.
Hosted a game on a PC behind router, did port mapping via Mono.Nat, and connected to it from the other pc - this worked perfectly fine.
Then I tried it without Mono.Nat - connection didn’t work.
So yep, Mono.Nat works.
Seems like it supports not only uPnP, but PMP too. It means that garbage Apple routers should still work with it. (not tested)
FYI, Mono.Nat is insanely buggy, and while it does work on some routers in my experience it will fail on a ton of them. I did extensive testing of Mono.Nat for Bolt, and while Bolt still uses Mono.Nat since no other free option is available, don’t bet on it actually working on a production environment.
1.2.21 IIRC, I tested Mono.Nat in both a development environment (about ~20-30 different routers makes/models in total) and also in a production environment in the game ‘The Forest’.
Oh I didn’t notice that someone actually answered in the end :o
I look into webrtc for now as I will try my best to get my game running in WebGL. It supports nat traversal. Until I get this working I am back to the old unity networking
Are we supposed to compile it outside Unity3D ? I defined NET35 and it still doesn’t work
– EDIT:
Yep. Compiled it, so now it works just fine. Thanks m8.
Getting weird results though. GetExternalIPAsync gives me 10.19.52.17 instead of my actual public ip address.
Owait, that’s my router or ISP doing something stupid.
@michael.catanzariti Really appreciate you porting Open.NAT to work with unity! Just wondering, all these Async calls that use System.Threading.Task 's. I haven’t had any luck using Tasks in Unity. Am I supposed to avoid the async calls? or am I using Tasks wrong
The example there doesn’t include automatic port forwarding but if there is interest I can put one together. I was able to get Open.NAT compiled on windows without any major problems and the port forwarding seems to work, at least in my tests so far.