Godot Engine

Godot Engine

Multiplayer: Any way around port forwarding?
I'm making a 1v1 game, where one player must connect to another to play. Currently via direct IP, but I'll figure out a matchmaking system as I get the gameplay more nailed down.

Problem is, in order to play behind a router I have to set up port forwarding, now that's fine for testing, I know what I'm doing.. but lets be honest, these days people either don't know or can't be bothered to port forward. If I release my game without sorting this out I guarantee 90% of reviews are going to be "couldn't connect to my friend, doesn't work, ♥♥♥♥ game 0/10"

Does anyone have a solution for this?


Update: I've done it! I got the game on Steam and it works flawlessly!
Replaced all my RPC calls with sending packets to the steam lobby, which took a bit of figuring out, but it works perfectly! Thank you so much!
En son Lucius Caesar tarafından düzenlendi; 24 Kas 2020 @ 7:16
< >
31 yorumdan 1 ile 15 arası gösteriliyor
I can't give you specific instructions on how-to with Godot, but you can research NAT Punch-through and that should get you going in the right direction.
İlk olarak Valdar tarafından gönderildi:
I can't give you specific instructions on how-to with Godot, but you can research NAT Punch-through and that should get you going in the right direction.
Actually that was the first thing I looked for but couldnt find any Godot specific implementations, mostly just finding people asking if Godot supports it,and being told no. But I'll give it another search. Thanks
En son Lucius Caesar tarafından düzenlendi; 16 Eki 2020 @ 4:26
The solution you're looking for is probably a STUN/TURN server to act as an intermediary.
Unfortunately, Godot's networking doesn't have support for that in the engine yet, though there is a proposal to add it: https://github.com/godotengine/godot-proposals/issues/434
hmmm, sounds like even if Godot eventually supports NAT punchthrough (and I think STUN/TURN is either the same thing or similar? it's explanation looks similar to me) I'll need a separate server to mediate the p2p connections which I was hoping to avoid... I might have to just make it based on a master server, treat it like an MMO almost but I was hoping to avoid having to rent big servers... at least it would mean I can handle matchmaking more easily I guess.

Thanks for the replies.
Shouldn't Godot be able to handle P2P?
As far as I know there shouldn't be an issue with connecting through IP addresses etc.

Also, Port Forwarding is widely used across several games.
Take Counter-Strike 1.6 for example, you need to port forward if you want to host a server for other players.
İlk olarak zeeb tarafından gönderildi:
Shouldn't Godot be able to handle P2P?
As far as I know there shouldn't be an issue with connecting through IP addresses etc.

Also, Port Forwarding is widely used across several games.
Take Counter-Strike 1.6 for example, you need to port forward if you want to host a server for other players.
I guarantee you any game that came out today that required port forwarding and didn't at least have loads of dedicated servers ready to go as an alternative would be blasted.



port forwarding is used in a variety of older games with a dedicated fanbase, it's not viable today when people expect to just click 'start game' and have their friend join them


As for your first point... should it? I'm guessing it wouldnt be with the Enet implementation if there is a way.
En son Lucius Caesar tarafından düzenlendi; 17 Eki 2020 @ 4:04
Bu konunun sahibi, bu iletinin ilk konuyu cevapladığını belirtti.
If you're planning on being Steam only, then this might help:
https://gramps.github.io/GodotSteam/tutorials-lobbies-p2p.html
İlk olarak tin tarafından gönderildi:
If you're planning on being Steam only, then this might help:
https://gramps.github.io/GodotSteam/tutorials-lobbies-p2p.html
This looks very VERY promising. Thank you so much.

Since you're making a 1v1 game, I'm going to assume it's PvP based as well. It would probably be better to have clients connect to a server to delegates packets to each other. Otherwise, you're giving out IP addresses willy nilly which will likely cause issues in the future when people start abusing the fact they can get their opponents IP address and do anything from nothing to ddosing them.

I'd be more worried about that than assuming my users are too dumb to port forward.
İlk olarak Ricky Sauce tarafından gönderildi:
Since you're making a 1v1 game, I'm going to assume it's PvP based as well. It would probably be better to have clients connect to a server to delegates packets to each other. Otherwise, you're giving out IP addresses willy nilly which will likely cause issues in the future when people start abusing the fact they can get their opponents IP address and do anything from nothing to ddosing them.

I'd be more worried about that than assuming my users are too dumb to port forward.

Yeah - nah. Having to forward ports is a much bigger problem. For starters, not everyone has a public IP to begin with, especially on mobiles or residential grade internet in Asian countries. If the NAT is done at your ISP, you're not going to be forwarding any ports.
If you want reliable P2P without port-forwarding behind NAT enabled routing, you’ll need a public IP server. Then you need to implement Hole Punching, sometimes called NAT Punch-through. This is basically some p2p code on your client-side software/game and a rendezvous protocol service on the server. Several ISP-type companies offer such a service for a reasonable fee. I know it can be done through DockerHub (maybe with a standard free account; I’m not sure if you need a premium account or not). As mentioned, the server could be Steam, and they will do the dirty work for you. Also, you could possibly even do it with Dynamic DNS, but I’ve never tried it.
For anyone who is interested, here is an excellent article by Bryan Ford explaining pretty much everything you need to know regarding how and why this is necessary in P2P across NAT (complete with diagrams and references, including RFCs).
https://bford.info/pub/net/p2pnat/
İlk olarak CheekyG46 tarafından gönderildi:
Sorry if this is a little late but you could consider telling your users about reverse proxies like Hamachi or Ngrok. Otherwise, you would need to probably rent a server that all games run from or implement hole-punching like others have said. Do note that Ngrok doesn't support UDP natively though.
Thanks for the response, I do appreciate it. I'm actually trying out tin's suggestion of using Steamworks p2p or lobbies via the GodotSteam module. Only just got my Steam Dev account sorted and GodotSteam compiled so starting tomorrow I'll be trying that out, Will definitely update here how that goes :) (completely unrelated.. seeing my game in my steam library is freaking wild!)
En son Lucius Caesar tarafından düzenlendi; 22 Kas 2020 @ 8:20
İlk olarak tin tarafından gönderildi:
If you're planning on being Steam only, then this might help:
https://gramps.github.io/GodotSteam/tutorials-lobbies-p2p.html


I've done it! I got the game on Steam and it works flawlessly!
Replaced all my RPC calls with sending packets to the steam lobby, which took a bit of figuring out, but it works perfectly! Thank you so much!
Hey, that's awe
some that you got it working. Grats!
< >
31 yorumdan 1 ile 15 arası gösteriliyor
Sayfa başına: 1530 50

Gönderilme Tarihi: 16 Eki 2020 @ 4:02
İleti: 31