uNetworking / uNetworking/uWebSockets

Fragmented send (todo: compression)

Open
#1,491 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

WebSockets
Dominant language
C++
Stars
19k
Forks
1.9k
Avg merge
3h 24m
Merged PRs (30d)
5

Description

Node can't create strings greater than about 1 GB, and Buffers max out at around 2GB. Because of this limitation I've broken up the message into small chunks. I can then send each chunk over the http server like this:

response.cork(() => {
  // ... I've omitted the header write steps for brevity

  for (const chunk of chunks) response.write(chunk);
  response.end();
});

And this works beautifully.

I've tried to find a way to do this using the ws api but send seems to require the whole message. Is there a way to stream chunks into send, or maybe send individual websocket message fragments from JavaScript?

_ observation: even if I can solve this issue the receiving end would need to be able to handle the large ArrayBuffer it will ultimately receive in the single message event - but that is a problem for another day. 😅 `

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the ws API's send path and the issue discussion, then compare it with Node's response.write chunking example. Determine whether fragmented sends or compression is the requested scope and identify the relevant implementation and tests from there. Done means the supported behavior and its acceptance criteria are documented and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript
Domain
backend, networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.