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:
const SERVER_PORT = 54321
var peer = ENetMultiplayerPeer.new()
var multiplayer_api = null
var first_arg = OS.get_cmdline_args()
var pid = first_arg.to_int()
if pid == 1:
err = peer.create_server(SERVER_PORT, MAX_PLAYERS)
err = peer.create_client("127.0.0.1", SERVER_PORT)
multiplayer_api.multiplayer_peer = peer
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).