WebSocket not receiving anymore updates after initial connection

Godot web socket client is not receiving anymore updates from Revolt web socket server (developers.revolt.chat/stack/…/establishing) after first data is received

first data is an Authentication success message:


<span style="color:#323232;">{
</span><span style="color:#323232;">  "type": "Authenticated"
</span><span style="color:#323232;">}
</span>

This success message comes when a successful token is received.

Since there are no updates and you cannot send any data after initial connection (data_received never called again, so put_packet() not working apparently), the token will have to be in query parameters:

wss://ws.revolt.chat/?version=1&format=json&token={token}

in order to even receive that success message.

An issue relating to web sockets was opened: github.com/godotengine/godot/issues/27560

The user claims that one of the headers causes the connection to cease.

The problem header is Connection: close, Upgrade


<span style="color:#323232;">    GET / HTTP/1.1
</span><span style="color:#323232;">    Pragma: no-cache
</span><span style="color:#323232;">    Cache-Control: no-cache
</span><span style="color:#323232;">    Host: echo.websocket.org
</span><span style="color:#323232;">    Upgrade: websocket
</span><span style="color:#323232;">    Connection: close, Upgrade
</span><span style="color:#323232;">    Sec-WebSocket-Key: HKWU1xOVV6PP6HXjcIWMDQ==
</span><span style="color:#323232;">    Sec-WebSocket-Version: 13
</span><span style="color:#323232;">
</span><span style="color:#323232;">    HTTP/1.1 101 Web Socket Protocol Handshake
</span><span style="color:#323232;">    Connection: Upgrade
</span><span style="color:#323232;">    Date: Sun, 31 Mar 2019 19:09:01 GMT
</span><span style="color:#323232;">    Sec-WebSocket-Accept: 0IHc3riAKJz52YmkLVcWrDHvaYs=
</span><span style="color:#323232;">    Server: Kaazing Gateway
</span><span style="color:#323232;">    Upgrade: websocket
</span>

IMPORTANT!!

What SHOULD happen and what happens on other clients like websocketking, piehost, or this one is receiving a READY update

the big issue:

connect_to_url() is the only thing that sends data or the connection closes or a protocol error

It would be of great help if anyone could give any little piece of knowledge or suggestion on this. code

MarshReaper,
@MarshReaper@lemmy.world avatar

I wouldn’t have gotten here without doing almost all of the previous steps. I even learned a lot about Godot and other libraries.

To solve this issue, go to PROJECT SETTINGS -> NETWORK -> LIMITS -> Max In Buffer (KB) & Max Out Buffer (KB) to a generous 1024 AND (I think) set Max Buffer (Power of 2) to a whopping 256.

MarshReaper,
@MarshReaper@lemmy.world avatar

UPDATE

I posted this before testing out an older version of godot and it seems to work just great! But as in the github issue, that is because of changes with how the protocols worked and what headers are sent!

Here is the code for use in Godot 3.1.1:


<span style="color:#323232;">extends Node
</span><span style="color:#323232;">
</span><span style="color:#323232;">var _client = WebSocketClient.new()
</span><span style="color:#323232;">
</span><span style="color:#323232;">func _ready():
</span><span style="color:#323232;">	print("connecting...")
</span><span style="color:#323232;">	_client.connect("connection_closed", self, "ws_closed")
</span><span style="color:#323232;">	_client.connect("connection_error", self, "ws_connection_error")
</span><span style="color:#323232;">	_client.connect("connection_established", self, "ws_connection_established")
</span><span style="color:#323232;">	_client.connect("server_close_request", self, "ws_close_request")
</span><span style="color:#323232;">	_client.connect_to_url("wss://ws.revolt.chat/?version=1&format=json&token={token}")
</span><span style="color:#323232;">
</span><span style="color:#323232;">func ws_closed(clean):
</span><span style="color:#323232;">	if !clean:
</span><span style="color:#323232;">		print("websocket closed")
</span><span style="color:#323232;">	else:
</span><span style="color:#323232;">		print("websocket closed cleanly")
</span><span style="color:#323232;">
</span><span style="color:#323232;">func ws_connection_error():
</span><span style="color:#323232;">	print("websocket connection failed")
</span><span style="color:#323232;">
</span><span style="color:#323232;">func ws_connection_established(protocol):
</span><span style="color:#323232;">	print("we're connected using protocol: ", protocol)
</span><span style="color:#323232;">
</span><span style="color:#323232;">func ws_close_request(code, reason):
</span><span style="color:#323232;">	print("closed with code: ", code, " and reason: ", reason)
</span><span style="color:#323232;">
</span><span style="color:#323232;">func _process(delta):
</span><span style="color:#323232;">	if _client.get_connection_status() == WebSocketClient.CONNECTION_DISCONNECTED:
</span><span style="color:#323232;">		return
</span><span style="color:#323232;">	print(_client.get_peer(1).get_packet().get_string_from_utf8())
</span><span style="color:#323232;">	_client.poll()
</span>
  • All
  • Subscribed
  • Moderated
  • Favorites
  • godot@programming.dev
  • PowerRangers
  • DreamBathrooms
  • thenastyranch
  • magazineikmin
  • mdbf
  • Youngstown
  • osvaldo12
  • slotface
  • everett
  • rosin
  • hgfsjryuu7
  • kavyap
  • tsrsr
  • ngwrru68w68
  • Leos
  • khanakhh
  • cisconetworking
  • modclub
  • GTA5RPClips
  • Durango
  • InstantRegret
  • vwfavf
  • tacticalgear
  • tester
  • cubers
  • ethstaker
  • normalnudes
  • anitta
  • All magazines