Client always returns OK even when the server is offline.

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

Hi,

I am trying to make a simple game played over the internet. I was looking for a method that will tell me that the server is unreachable.

I used create_client(ip,port) method and get_connection_status but they always return 0 even when the server is offline.

The question is if there’s a method that actually support this or did I do sth wrong.

My Client is running on Windows (directly from the engine)

If you need more informations I will update it ASAP.

:bust_in_silhouette: Reply From: tangy

Hi, this looks like an old question, but I had the same issue and I think I figured it out:

The error code returned by create_client(ip,port) will only let you know if it failed due to ERR_ALREADY_IN_USE or ERR_CANT_CREATE. So, once you get OK, the connection attempt takes time, so observing the signals connected_to_server and connection_failed will notify you when success or failure actually occurs - success is pretty much immediate in my testing where failure seems to happen after a timeout.

BTW, I’m new to Godot so this may not be entirely correct (please chime in to correct me if I’m wrong).