0 votes

I'm trying to set up simple networking. I tried following these tutorials: 1, 2, but didn't manage to set up a connection. Simplified code:

extends Node2D

const SERVER_PORT = 54321
var peer = ENetMultiplayerPeer.new()
var multiplayer_api = null

func _ready():
    var first_arg = OS.get_cmdline_args()[0]
    var pid = first_arg.to_int()
    if pid == 1:
        err = peer.create_server(SERVER_PORT, MAX_PLAYERS)
    else:
        err = peer.create_client("127.0.0.1", SERVER_PORT)

    multiplayer_api.multiplayer_peer = peer

func _log():
    print("Connected peers", multiplayer_api.get_peers())
    print("connection status", peer.get_connection_status())

On the server, I see CONNECTION_CONNECTED, and if I try to run another process with pid=1, I get a connection error. On the client, I always see CONNECTION_CONNECTING, whether I put "127.0.0.1", "localhost", or "192.168.1.X". I also tried binding the same IP on the server, to no avail.

I also tried changing to Websockets, and observed that now the port is opened over TCP instead of UDP, but it didn't resolve the issue.

Any idea what I'm doing wrong and how to debug this issue? Fwiw, I am testing this on Linux (Ubuntu 22.04).

Godot version 4.0-alpha-14
in Engine by (132 points)
edited by

1 Answer

0 votes

I ported the code to 3.5, where it works just fine, what suggests this is an issue with the engine itself. I opened a bug report.

by (132 points)
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 Frequently asked questions and 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 [email protected] with your username.