Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Handle multiple WebSocket frames within a TCP packet#338

Merged
me-no-dev merged 1 commit intome-no-dev:masterfrom
adapt0:wsmultipleframes
Jul 24, 2018
Merged

Handle multiple WebSocket frames within a TCP packet#338
me-no-dev merged 1 commit intome-no-dev:masterfrom
adapt0:wsmultipleframes

Conversation

@adapt0
Copy link
Copy Markdown
Contributor

@adapt0 adapt0 commented Mar 18, 2018

This PR adds support for handling multiple WebSocket frames within a TCP packet.

Have been encountering an issue on Chrome 64.0.3282.186 where WebSocket message requests are missing during initial page load. Typically when there are a number of HTTP requests in flight.

Can reproduce by having the browser buffer WebSocket frames before sending:

ws = new WebSocket('ws://192.168.1.149/api/v1');
ws.onopen = function() {
  ws.send('#'.repeat(10000));
  for (var i = 0; i < 10; ++i) ws.send(i.toString());
}

Expect: bunch of fragmented frames followed by 10 short messages
Actual: bunch of fragmented frames

Frames are silently discarded when the received frame length is no longer a function of the received packet size. This PR adds a loop and adjusts the length checks to take into account that multiple frames may exist within a TCP packet.

@me-no-dev me-no-dev merged commit b6b43d3 into me-no-dev:master Jul 24, 2018
@me-no-dev
Copy link
Copy Markdown
Owner

Hey! Thanks for doing this! Really sorry that I have not had the time to take care of this repo recently

@adapt0 adapt0 deleted the wsmultipleframes branch September 14, 2018 23:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants