WebSocketClient stuck at CONNECTION_CONNECTING

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

Hello, I’m trying to connect from godot game into my websocket server written in java.

When trying to connect, godot becomes stuck at CONNECTION_CONNECTING state. My java server is 100% working properly, it accepts connections from other sources without issues. Only godot has this problem.

When running code provided below the only output is “Connecting to ws://localhost:1369”. What am I doing wrong here?

 extends Node

var ws: WebSocketClient = null

func _ready():
	ws = WebSocketClient.new()
	ws.connect("connection_established", self, "_connection_established")
	ws.connect("connection_closed", self, "_connection_closed")
	ws.connect("connection_error", self, "_connection_error")

	var url = "ws://localhost:1369"
	print("Connecting to " + url)

func _connection_established(protocol):
	print("Connection established with protocol: ", protocol)

func _connection_closed():
	print("Connection closed")

func _connection_error():
	print("Connection error")

func _process(_delta):
	if ws.get_connection_status() == ws.CONNECTION_CONNECTING || ws.get_connection_status() == ws.CONNECTION_CONNECTED:

Does ws.connect_to_url(url) return OK? i.e. var err = ws.connect_to_url(url)

SteveSmith | 2022-02-08 02:21

yes, it does. It even registers on my server, but never sends/recieves any data nor does it fir any callback connected methods

YouHaveTrouble | 2022-02-08 21:53