You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the Deflate extention is added to a Soketto server, it seems as if there is a problem decoding messages.
To reproduce run this in one terminal:
# The example here has logging and a browser can connect, so easy place to test:
git checkout jsdw-hyper-soketto
RUST_LOG=trace cargo run --example hyper_server --features 'http deflate'
And then in a web browser (I used firefox), connect to localhost:3000 and run this in the console:
var socket = new WebSocket("ws://localhost:3000");
socket.onmessage = function(msg) { console.log(msg) };
socket.send("aaa");
socket.send("aaa");
After running the second socket.send, we don't get an echo response, and the logs indicate that the server failed and the loop ended:
Interestingly, if you send a message like "a" or "aa" instead of "aaa" it seems OK.
My guess is that the way we decode messages should be stateful, but isn't (we create a decoder each time a message comes in, attempt to decode it, and then throw the decoder away). I get the impression (see links below) that the default decoding strategy may use a sliding window approach which cares about past state to help decode future state. We can see in the log messages that the length of the message payload decreases for the second "aaa" sent, implying that the encoding is different, and so probably based on past state (or that we are dropping bytes, which I think unlikely as no issues seen without the deflate extension).
A couple of issues that cropped up in my searching and may be useful:
When the Deflate extention is added to a Soketto server, it seems as if there is a problem decoding messages.
To reproduce run this in one terminal:
And then in a web browser (I used firefox), connect to
localhost:3000
and run this in the console:After running the second
socket.send
, we don't get an echo response, and the logs indicate that the server failed and the loop ended:Interestingly, if you send a message like "a" or "aa" instead of "aaa" it seems OK.
My guess is that the way we decode messages should be stateful, but isn't (we create a decoder each time a message comes in, attempt to decode it, and then throw the decoder away). I get the impression (see links below) that the default decoding strategy may use a sliding window approach which cares about past state to help decode future state. We can see in the log messages that the length of the message payload decreases for the second "aaa" sent, implying that the encoding is different, and so probably based on past state (or that we are dropping bytes, which I think unlikely as no issues seen without the deflate extension).
A couple of issues that cropped up in my searching and may be useful:
And the RFC around how this should be implemented:
https://datatracker.ietf.org/doc/html/rfc7692#section-7.2.2
The text was updated successfully, but these errors were encountered: