godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.15k stars 21.19k forks source link

Can't connect to websocket in 3.1 #22401

Closed ArthaTi closed 6 years ago

ArthaTi commented 6 years ago

Godot version: v.3-1.alpha-official

OS/device including version: Everything except HTML5, confirmed on Windows Desktop, Android and normal Windows debug.

Issue description: I've tried connecting to websockets at localhost, 127.0.0.1, my domain address, my server IP; with and all without prefixing the URL with ws:// or wss://. Website certificate is saved in Godot's files. None of it ever worked except when exporting to HTML5, where it succeeds. The server doesn't ever receive any signals from Godot. Client is defined as a class property with var client = WebSocketClient.new() in a global/singleton. App is stuck connecting and doesn't report any errors. client.get_connection_status() returns 1 (WebSocketClient.CONNECTION_CONNECTING). Nor Godot or the game is blocked by firewall.

I've also created a question 2 days ago: https://godotengine.org/qa/33572/connecting-to-websockets-doesnt-end

Steps to reproduce: Create a websocket client and try to connect.

Minimal reproduction project: websocket.zip

Also, I forgot to add the client.poll() method in _process. It doesn't change anything anyway.

Faless commented 6 years ago

@Soaku did you try the demo here: https://github.com/LudiDorici/godot-websocket/tree/master/websocket_chat_demo

Faless commented 6 years ago

Also, I forgot to add the client.poll() method in _process. It doesn't change anything anyway.

Well, if you don't poll, it won't work in native client. But HTML5 does, because the browser does that for you and there is no way to prevent that. That would explain why HTML5 was working and native was not.

If you think you are polling now, but it still does nothing and you get no error. I suspect there is either an error in your code, or some troubles with your local server (less likely).

Other people have been using WebSocket on Windows and reported it to work.

Let me know if the linked demo works for you.

ArthaTi commented 6 years ago

@Faless Sorry for the trouble, didn't really understand how the .poll method works. Fixed it now. Thanks!

dirkk0 commented 5 years ago

From this and various other threads I compiled a working example here. https://github.com/dirkk0/nodejs-godot-websockets