Godot version:
Godot Engine v3.1.dev.calinou.43dc050 (obtained from https://hugo.pro/projects/godot-builds/)
OS/device including version:
Windows 10 Home v1803 (April 2018 update) x64
Issue description:
I don't seem to be able to use WebSocketClient for anything that isn't multiplayer. Any attempt to send packets will result in error code 3 (ERR_UNCONFIGURED), and attempts to read received packets will result in the same error. (Godot, from testing on the Discord websocket, seems to recognize when I get packets -- I just can't read them, as the packets are always null when I read them with get_var().)
After digging around, I seem to have located the places where the errors might be coming from; see line 113 and line 131, both of websocket_multiplayer.cpp.
Hopefully this isn't just me missing a step. I want to use the websocket implementation for non-multiplayer functions.
Steps to reproduce:
Try to send or receive anything to/from a websocket using the WebSocketClient class.
Minimal reproduction project:
Websocket issues.zip (This uses ws://echo.websocket.org for testing)
CC @godotengine/network
@akien-mga was that what you mean to CC? It doesn't link anywhere
@Zephilinox It mentions everyone in the godotengine/network team so that they get notified of the issue :slightly_smiling_face:
@LikeLakers2 you need to call client.get_peer(1).get_available_packet_count() and client.get_peer(1).get_packet().
The version you are using (client.get_available_packet_count() and client.get_packet()) only works when gd_mp_api is enabled)
@Faless Thanks. Can that maybe be documented then, if that's how it's supposed to work? I looked through the documentation and found no mention that I needed to use get_peer(1).get_packet() instead of get_packet().
@LikeLakers2 you are right, it should be documented. I'm reopening the issue and adding the documentation tag, I'll try to make a PR over the WE
@Faless While it doesn't happen on the build I was using to make this issue, the latest build from that website (v3.1.dev.calinou.6c569c9) seems to have issues sending packets. I'm unsure what changed between the issue being created and now, but when I send any packet (whether through get_peer(1).put_var() or get_peer(1).put_packet() with the appropriate types), the program freezes before abruptly sending me back to the editor. In the console (not the output tab, the console that appears alongside the editor), this is what's shown:
Nothing read: Invalid argument
ERROR: read: Server Disconnected!
At: drivers/windows/stream_peer_tcp_winsock.cpp:203
Besides adding get_peer(1) to where it's needed, the code I'm using is all the same as the reproduction project from the original post.
Yeah, I opened an issue about that, see #20696
On Fri, Aug 3, 2018, 22:17 LikeLakers2 notifications@github.com wrote:
@Faless https://github.com/Faless While it doesn't happen on the build
I was using to make this issue, the latest build from that website
(v3.1.dev.calinou.6c569c9) seems to have issues sending packets. I'm unsure
what changed between the issue being created and now, but when I send any
packet (whether through get_peer(1).put_var() or get_peer(1).put_packet())
the program freezes before abruptly sending me back to the editor. In the
console (not the output tab, the console that appears alongside the
editor), this is what's shown:Nothing read: Invalid argument
ERROR: read: Server Disconnected!At: drivers/windows/stream_peer_tcp_winsock.cpp:203
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/20289#issuecomment-410364979,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABnBbnLiW5R1ZBmxWswao_yfZB_hrOFYks5uNK_BgaJpZM4VXJji
.
I'm unsure if I should open a new issue about this, but in writing my Discord implementation for Godot, I notice Discord isn't registering the client as disconnected immediately. I took a small look into it, and unless I'm misunderstanding the protocol or how Godot's websockets are structured, it seems like Godot's implementation of websockets isn't sending a close frame when client.get_peer(1).close() or client.disconnect_from_host() is called? I'm unsure what to do about this.
On that note, I also can't read the close event codes sent to my client by Discord's gateway.
EDIT: After sleeping on it, I think it's better if I make a separate issue for this. I'll get to that sometime.
@VitaZheltyakov That's not the issue I'm having. The problem I described in my last message was some packets not being sent/received like they're supposed to.
you are right, it should be documented. I'm reopening the issue and adding the documentation tag, I'll try to make a PR over the WE
@Faless Was this done in the end?
@akien-mga mention in the docs to use WebSocketClient.get_peer(1).put/get_packet() instead of WebSocketClient.get/put_packet() when not using the Multiplayer API. I'll make a PR ASAP, I totally forgot about this.