I am working on a multiplayer (LAN) game and I have been able to test things by launching my game from the Godot editor as well as launching it from VS Code. The two instances see each other through multicast discovery and until recently the client could connect to the server. I say "until recently", because I upgraded to a newer M1 Mac from my older Intel Mac and now the client can't connect to the server (on localhost). Strangely enough the client can connect when it is run on a remote machine.
I'm using the LanServerBroadcast add on for server discovery. The discovery still works and it reports the correct IP and port. The IP returned is always the private IP of my Mac (even if I call peer.set_bind_ip
to set it to '127.0.0.1'). I have tried forcing the client to use '127.0.0.1' or 'localhost' instead of the private IP to no effect. The connection always times out. Again the weird thing is that I have no problem connecting from a remote machine.
Since this works on my old Mac and not on the new one (both running the latest MacOS Monterey) I thinking there must be some weird setting with respect to UDP on localhost that is somehow different on the two machines, but I have no idea what that would be (firewall settings are the same). Both Macs are running Godot 3.4.4.
The code I use to create the server is the following:
var peer = NetworkedMultiplayerENet.new()
var result = peer.create_server(ServerInfo.PORT)
if result == OK:
get_tree().set_network_peer(peer)
print("Game hosted")
else:
print("Failed to host game")
and the code for the client is:
var peer = NetworkedMultiplayerENet.new()
get_tree().connect("connection_succeeded", self, "_connection_succeeded")
peer.create_client(server_info.ip, server_info.port)
get_tree().set_network_peer(peer)
Does anyone have any idea why I can connect from a remote host, but not from localhost?