How to make networking work

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sygi

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 =
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)
        err = peer.create_client("", 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 “”, “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).

:bust_in_silhouette: Reply From: sygi

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.