Skip to content

Allow programmatic configuration of maximum frame size? #55

@mccolljr

Description

@mccolljr

What problem are you trying to solve?

I work on a web portal that needs to speak a raw binary protocol. To do this, our application sends binary messages over a web socket, and the server application forwards the frame contents to the TCP socket communicating with the binary protocol server. This happens on a per-frame basis. Our ability to modify the binary protocol server is limited. Under the some common (for us) network conditions, the binary protocol server times us out while waiting on the next chunk of data when a single frame cannot be transferred within the timeout period. To ensure smooth communication, we'd like to be able to limit the maximum frame size sent over the web socket connection. As far as I can tell, there is no way to control the maximum frame size sent by WebSocket clients in the browser.

What solutions exist today?

  1. Implement a custom chunking scheme in user code, on top of the web socket protocol. In general, this is unfortunate because it introduces a need for both the server and client to be aware of this additional layer, and is redundant since the web socket protocol already supports continuation frames for data chunking. In our case, we are unable to modify the server environment to support a custom protocol.
  2. Bypass the web socket protocol and send large payloads via some other mechanism (POST request). This is not a good solution because it requires stepping outside of the normal flow of communication and requires complex user code to correctly interleave the data transfers over the two different pathways. In our case, we are unable to modify the server environment to support this kind of scheme.
  3. (As far as I know, there is no other solution available in the browser)

How would you solve it?

I would like a way to pass maxFrameSize (or maxTextFrameSize and maxBinaryFrameSize) to the WebSocket constructor so that I can guarantee large messages will be split into appropriately sized frames.

Anything else?

In my testing, I discovered that:

  1. Firefox appears to send large binary messages in a single frame if it can, while
  2. Chrome appears to break large binary messages into frames of ~130Kb

It would be nice if there was a standardized way to control this behavior to ensure consistent behavior across different browsers

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interest

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions