Godot Version
Godot 4.3 Stable-Mono
Question
Hello everyone!
I’m having an issue with my networked game where when I run two instances on the same machine they can communicate with each other, and it all works well. However when I put the game on another PC that I have in the house and have one instance running on that machine which acts as the client and another instance on a different machine that acts as a server, they simply don’t connect. They are on the same network and I’ve set it up like this:
SERVER:
Port: 33333
Local IP Address: 192.168.X.X
CLIENT:
Port: 33333
IP: The local address of the server on the same network (192.168.X.X)
I’ve also tried port forwarding and using my router’s public IP address, but this still doesn’t work.
The code that makes the server is here:
public void HostServer()
{
// Creates server
GD.Print("Server: Hosting server...");
Server = new ENetMultiplayerPeer();
Server.SetBindIP(IP);
Error serverError = Server.CreateServer(Port, MaxPlayers);
switch (serverError)
{
case Error.Ok:
ResultText.Text = "Server successfully created!";
GD.Print("Server: Server successfully created!");
break;
case Error.CantCreate:
ResultText.Text = "Server couldn't be created!";
GD.Print("Server: Server couldn't be created!");
return;
case Error.AlreadyInUse:
ResultText.Text = "A server has already been opened!";
GD.Print("Server: A server has already been opened!");
return;
}
Multiplayer.MultiplayerPeer = Server;
Multiplayer.PeerConnected += Multiplayer_PeerConnected;
}
And the code for the client is here:
// Creates client
GD.Print("Connecting Client...");
Client = new ENetMultiplayerPeer();
Error clientError = Client.CreateClient(IP, Port);
switch (clientError)
{
case Error.Ok:
GD.Print("Client successfully connected!");
break;
case Error.CantCreate:
GD.PrintErr("Client couldn't be created!");
return;
case Error.AlreadyInUse:
GD.PrintErr("A different client has already been opened!");
return;
}
Multiplayer.MultiplayerPeer = Client;