0 votes

Good afternoon,
I am trying to setup a simple websocket client following this documentation.
The problem is, even if the code is identical to the one in the guide, no websocket packet is received by the server.
I tried to use both put_packet and put_var, in addition to trying to change the write mode using:

_client.get_peer(1).set_write_mode(WebSocketPeer.WRITE_MODE_TEXT)

The websocket server is written in Java using Undertow and, after making some tests, I concluded that it is working fine because it can receive packets from other sources, but not from Godot.
Opening and closing the connection works perfectly fine and I am able to receive data from the server.
In addition, I get a status code of 0 (no error) from the put_packet function, even if the server does not receive it.

Can you help me identify the issue?

Thanks in advance

Godot version 3.2.3 stable
in Engine by (21 points)

1 Answer

0 votes
Best answer

Found out that _client.get_peer(1).set_write_mode(WebSocketPeer.WRITE_MODE_TEXT) is not enough to send packets as Strings and the server kept receiving array of bytes instead of strings, thus ignoring the packets.

by (21 points)
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.