lucaspoffo/renet

Document hosting behind port-forwarded NAT

Opened this issue · 2 comments

Hosting behind a NAT router requires passing a different public IP to the server config and the socket. This is not visible in the examples or anything I had read. Doing this incorrectly causes no connections to go through, with no warnings.

Maybe there could be a comment in the examples. Above the line that builds the server config would be a good place in my opininon.

Original issue

I originally wanted to write a feature request, then realized it was already possible, just not very clear.

Original Text The IP a server listens on must match the one a client connects to. This prevents hosting behind a NAT device (like a home router), as the server can't bind on the public IP of the entire network.

Hosting with port forwarding from home is a common thing when playing games with friends. I personally need it for testing my game from my personal computer.

Public address configuration seems to be a recurring cause of confusion. Adding some common scenarios in the readme or the doc should help, especially about NAT, port-forwarding, dedicated server... Maybe also add some external resources about it, but don't know which one.

I met this exact issue a few days ago. What exactly is the point of the NoHost error ? matching IP address once you're connected to an UDP socket doesn't make a lot of sense to me. Is it only for the Authentication side of things ?

Edit: So I went back digging into the RenetClient code. This problem only really occurs when you use Unsecure authentication, because you can only provide the one server address you use. I'm testing the connection over both local, LAN, and internet. So 3 different addresses (potentially). With secure authentication, it kinda goes away if you go through the hassle of setting up your external IP on the server configuration, but you might not know that (thinking aws hosting or similar. Plus it's way easier to just setup the server on 127.0.0.1 and proxy forward the traffic).