Can you not send some Unicode characters through websockets?

Godot Version

4.4 RC1

Question

I’m using a SignalR C# server and it requires a handshake to be sent with the 0x1E character (record separator) at the end, I’ve tried:

var handshake = "{\"protocol\":\"json\",\"version\":1}%c"
websocket.send_text(handshake % String.chr(30))

and

websocket.send_text("{\"protocol\":\"json\",\"version\":1}" + String.chr(30))

and neither work. I’ve even tried copying/pasting the character into the gdscript but nothing shows up (It shows up in VSCode though) and it doesn’t work either.

What am I doing wrong? Does gdscript just not let you send this character over websockets?

Managed to solve it after sleeping on it, I think the message was just sending too fast. In case anyone else uses SignalR and has this issue - here’s my code:

func connect_to_server():
    var err = websocket.connect_to_url(server_url)
    if err != OK:
        print("Failed to connect: ", err, " | WebSocket State: ", websocket.get_ready_state())
    else:
        await get_tree().create_timer(2.0).timeout
        var handshake = '{"protocol":"json","version":1}%c'
        handshake = handshake % String.chr(30)
        websocket.send_text(handshake)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.