client can't connect to server

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

So I’m working on a multiplayer game, and i want my server to run on a vm (debian), and my client to connect on it via the high level api : High level multiplayer — Godot Engine (3.0) documentation in English

My game (client and server) works fine locally.

On my vm the port I need is open, tested remotly with ‘nc -u myvmip myport’, my vm listening with ‘nc -ul -p myport’, everything is working.
Remote ssh connection on port 22 is working…

But when I launch my godot server, my remote godot client can’t connect. Any ideas ?

:bust_in_silhouette: Reply From: Nomys_Tempar

Ok some news on this.
I create my client with something like this :

export var SERVER_PORT = 8996
export var SERVER_IP = “127.0.0.1”

var peer = NetworkedMultiplayerENet.new()
peer.create_client(SERVER_IP, SERVER_PORT)
get_tree().set_network_peer(peer)

So it’s connecting to my local server. To connect with my distant server I just change the SERVER_IP value :

export var SERVER_IP = “my.own.distant.server”

Well, it doesn’t seems to work, my client is still triying to reach a local server, in my logs I found something like : inet_addr : “127.0.0.1”

Anyone knows why ? And how to point godot to the right adress ?

Ok so I found the issue :

export var SERVERPORT = 8996
export var SERVERIP = "mydistantserver"

func ready()
  var peer = NetworkedMultiplayerENet.new()
  peer.createclient(SERVERIP, SERVERPORT)
  gettree().setnetworkpeer(peer)

In this code, my server (also created in ready()) is using my var SERVERIP properly. But the problem was peer.createclient() doesn’t find SERVERIP so it was using localhost instead.

This is a weird behaviour…

Anyway I just rewrite a SERVERIP var inside ready() and it works fine !

Now, my code looks like that :

export var SERVERPORT = 8996 
export var SERVERIP = "mydistantserver"
func ready()
  var SERVERIP = "mydistantserver"
   var peer = NetworkedMultiplayerENet.new()  
  peer.createclient(SERVERIP, SERVERPORT)  
  gettree().setnetworkpeer(peer)

Nomys_Tempar | 2018-12-05 10:40