godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.15k stars 21.19k forks source link

Server IP #92086

Closed Airmancooma closed 6 months ago

Airmancooma commented 6 months ago

Tested versions

Tested versions

Reproducible in: Godot 4.2.2.
Not tested in other versions.

System information

Godot v4.2.2.stable (15073afe3) - Freedesktop SDK 23.08 (Flatpak runtime) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 580 Series (RADV POLARIS10) () - AMD Ryzen 5 3600 6-Core Processor (12 Threads)

Issue description

Issue description

The server is not hosting publicly and is therefore not accessible externally. I tested with and without specifying the IP address using server_peer.set_bind_ip(SERVER_IP), but it doesn't work either way. The firewall settings are correct, and the port is open, verified with a Python script. The port is open as checked via:

ubuntu@ubuntu:~$ sudo ss -tuln | grep :9090
udp   UNCONN 0      0                      *:9090             *:*          
ubuntu@ubuntu:~$

The issue is observed only when trying to access the server externally; it works fine on a local network.

Steps to reproduce

Steps to reproduce

Create a server in Godot 4.2.2. Attempt to bind the server to a specific IP address using server_peer.set_bind_ip(SERVER_IP). Check the port status using sudo ss -tuln | grep :9090. Attempt to access the server externally from another machine. Observations

Without specifying the IP address:

ubuntu@ubuntu:~$ sudo ss -tuln | grep :9090
udp   UNCONN 0      0                      *:9090             *:*          
ubuntu@ubuntu:~$
With specifying the IP address:
ubuntu@ubuntu:~$ sudo ss -tuln | grep :9090
udp   UNCONN 0      0       [::ffff:0.0.0.0]:9090             *:*          
ubuntu@ubuntu:~$

It seems to incorrectly set the IP address as [::ffff:0.0.0.0] instead of using IPv4.

Minimal reproduction project (MRP)

PityuPityu.zip

You need to set SERVER_IP and SERVER_IP_CLIENT at res://scripts/multiplayer/multiplayer_manager.gd

AThousandShips commented 6 months ago

This sounds like something you have to configure yourself in your firewall and router, this isn't something Godot can (or should) do automatically

Airmancooma commented 6 months ago

This sounds like something you have to configure yourself in your firewall and router, this isn't something Godot can (or should) do automatically

But it's not the router or the firewall; they are 100% configured correctly, and the port is definitely open. The issue is that Godot cannot bind the port. I wrote a Python server code that specifically used UDP on port 9090, and I was able to ping it remotely. So, the port is definitely open.

Airmancooma commented 6 months ago

Ok, it turns out the problem was with the Godot game; there was a typo in a random script.

Airmancooma commented 6 months ago

All right, it turns out this is a bug. If you use Node2D as the server starter, it doesn't work and doesn't create the server, even if the terminal says it does. However, if you use a regular Node, it creates the server.

func _ready():
    if OS.has_feature("dedicated_server"):
        print("Starting dedicated server...")
        MultiplayerManager.host()
Airmancooma commented 6 months ago

It turns out that this problem is somehow only happening to me.

AThousandShips commented 6 months ago

I'd suggest also asking for support in the forums for issues like this

Airmancooma commented 6 months ago

I'd suggest also asking for support in the forums for issues like this

Yeah, there was a conversation, just not on this forum, but I talked to people, and they didn't know what the problem was either. We still don't know, but it works now.