sitegui / nodejs-websocket

A node.js module for websocket server and client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Communication - failing to send 12 MB Buffer

metabench opened this issue · comments

I am making a distributed application that sends approx 12 MB of data to worker threads, and I'm trying to do so with nodejs-websocket. Currently I can't tell if the failure is on sending or receiving.

Has this package been tested with larger amounts of data, in the tens of MB?

Would it be worth being clear about what size limits there are for messages?

I am sending with:

connection.send(dataset_envelope_buffer);

Hi @metabench

This is by design: connection.send() sends the whole content as one frame, and the receiving side isn't expecting anything larger than 2MiB.

You can either/both:

  1. call ws.setMaxBufferLength(bytes) on the receiving side with a larger value;
  2. send multiple chunks by writing to a binary stream created with connection.beginBinary() on the sending side

You could tell the problem was this because the connection got closed with error 1009, as per the spec:

1009 indicates that an endpoint is terminating the connection because it has received a message that is too big for it to process.

Hope it works for you. If it doesn't let me know ;)