Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WS] Fix wslay multi-frame message parsing (again) #102128

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

Faless
Copy link
Collaborator

@Faless Faless commented Jan 28, 2025

We incorrectly assumed that the payload_length in the recv start callback of wslay was the final message size, but according to the WebSocket protocol, the payload length always refers to the current frame's payload size.

The protocol, in fact, do not include a "message payload" length on purpose to allow sending messages of unknown size without forcing the sender to buffer the whole message (RFC6455 Section 5.4).

This means a receiving peer has no way to know beforehand how long a message will be, and needs instead to keep track of the length of each frame until the FIN one is received to properly reconstruct the message at the end.

Fixes #101811 .
Closes #102038 .

We incorrectly assumed that the `payload_length` in the recv start
callback of wslay was the final message size, but according to the
WebSocket  protocol, the payload length always refers to the current
frame's payload size.

The protocol, in fact, do not include a "message payload" length on
purpose to allow sending messages of unknown size without forcing the
sender to buffer the whole message (RFC6455 Section 5.4).

This means a receiving peer has no way to know beforehand how long a
message will be, and needs instead to keep track of the length of each
frame until the FIN one is received to properly reconstruct the message
at the end.
@Repiteo Repiteo merged commit 4a7ce60 into godotengine:master Jan 31, 2025
19 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jan 31, 2025

Thanks!

@dsnopek
Copy link
Contributor

dsnopek commented Feb 2, 2025

I belatedly noticed this issue in beta2, and can confirm that this PR fixes it for me :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Websocket client cuts message after 2^15 bytes
4 participants