0 votes

Hey all,

I'm trying to set up p2p multiplayer, similar to the way Terraria handles things. Trying to connect via 127.0.0.1 works great, but when I try to connect to my friend's computer via his public IP, it doesn't work. My only lead is that connection_failed is triggered.

We suspected a firewall issue, but after configuring firewalls on both machines to allow the game through, the issue still occurs.

I'm using a NetworkedMultiplayerENet.

What could the issue be?

in Engine by (125 points)

I asked this question previously:
https://godotengine.org/qa/65718/private-vs-public-ip-addresses

After enabling port forwarding for both tcp and udp connections, it worked for me

Having each player manually enable port forwarding isn't feasible, so I'm looking into UPNP. I found this article: https://docs.godotengine.org/en/stable/classes/class_upnp.html#class-upnp-method-add-port-mapping

If I understand correctly, a single call to add_port_mapping() at game startup should fix this. Is it better security practice to add_port_mapping() only when hosting game, and to delete_port_mapping() when done? Or is it okay to simply leave the port mapping there?

EDIT: on second thought, this is beyond the scope of this question, so I'm opening a new thread.

You should just need port forwarding to host a server, not connect to it.

I don’t know much about upnp, sorry

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.