0 votes

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 : https://godot.readthedocs.io/en/3.0/tutorials/networking/high_level_multiplayer.html

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 ?

asked Jul 26, 2018 in Engine by Nomys_Tempar (20 points)
edited Jul 26, 2018 by Nomys_Tempar

1 Answer

0 votes

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

export var SERVERPORT = 8996
export var SERVER
IP = "127.0.0.1"

var peer = NetworkedMultiplayerENet.new()
peer.createclient(SERVERIP, SERVERPORT)
get
tree().setnetworkpeer(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 ?

answered Sep 12, 2018 by Nomys_Tempar (20 points)

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)
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 How to use this Q&A? before posting your first questions.