0 votes

I am trying to run my basic server:

extends Node

const SERVER_PORT = 31909
var network = NetworkedMultiplayerENet.new()
var max_players = 10

func _ready():

func StartServer():
    network.create_server(SERVER_PORT, max_players)
    network.set_bind_ip("<AWS Public IPv4>")
    print("Server started")
    network.connect("peer_connected", self, "_Peer_Connected")
    network.connect("peer_disconnected", self , "_Peer_Disconnected")

func _Peer_Connected(player_id):
    print("User " + str(player_id) + " connected")

func _Peer_Disconnected(player_id):
    print("User " + str(player_id) + " disconnected")

remote func message(message):
    print("received message")
    var client_id = get_tree().get_rpc_sender_id()
    rpc_id(client_id, "message", message)

With my basic Client:

extends Node

var network = NetworkedMultiplayerENet.new()
#var ip = ""
var ip = ""
var port = 1909

func _ready():

func ConnectToServer():
    print("connecting to Server")

    network.connect("connection_failed", self, "_OnConnectionFailed")
    network.connect("connection_succeeded", self, "_OnConnectionSucceded")

func _OnConnectionFailed():
    print("Failed to connect")

func _OnConnectionSucceded():
    print("Succesfully connected")
    rpc_id(1, "message", "Test Nachricht")

remote func message(message):

On my AWS EC2 Instance per this tutorial: https://urodelagames.github.io/2022/04/19/setting-up-godot-server-on-aws/
But I alway get this error:

ERROR: create_server: Condition "!host" is true. Returned: ERR_CANT_CREATE
   At: modules/enet/networked_multiplayer_enet.cpp:108.
ERROR: set_network_peer: Condition "p_peer.is_valid() && p_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED" is true.
   At: core/io/multiplayer_api.cpp:147.

I use Godot 3.3.3stable and Godotv3.3.3-stablelinuxserver.64. I already searched every link that comes up, when searching this error but nothing is relevent or helps...
And it really is strange, that when I run my client lokal I get the "peer_connected" signal but no message...

Godot version 3.3.3
in Engine by (22 points)
edited by

I solved the issue by switching to Godot 3.5 (of cause the godot linux server version too)

1 Answer

0 votes

Try setting the "network" variables to onready.

by (141 points)

Sadly this did not work, I also tried to initialize the network variable with NetworkedMultiplayerENet in the ConnectToServer function which also did not work...

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.