js-libp2p icon indicating copy to clipboard operation
js-libp2p copied to clipboard

[email protected] does not support chunks bigger than 2Mb anymore

Open alxroyer opened this issue 3 years ago • 3 comments

Severity:

Low

Description:

When receiving chunks of data bigger than 2Mb from a stream, Error: message size too large! errors are raised, while with [email protected], we could exchange chunks of 10Mb at least.

Not really an operational problem I guess. Quick workarounds easy to set up. But depending on the root cause, I can't say on my own whether that problem could hide a bigger one.

Steps to reproduce the error:

Using the scripts attached with #1342, launch the sender (3145728 = 3 * 1024 * 1024):

node libp2p-node.0.37.x.mjs --send=path-to-a-big-file --size=3145728

then launch the receiver:

node libp2p-node.0.37.x.mjs --connect=/address/of/sender/node

Error displayed by the receiver:

file:///.../node_modules/@libp2p/mplex/dist/src/restrict-size.js:14
            throw Object.assign(new Error('message size too large!'), { code: 'ERR_MSG_TOO_BIG' });
                                ^

Error: message size too large!
    at checkSize (file:///.../node_modules/@libp2p/mplex/dist/src/restrict-size.js:14:33)
    at Array.forEach (<anonymous>)
    at restrictSize (file:///.../node_modules/@libp2p/mplex/dist/src/restrict-size.js:21:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async file:///.../node_modules/@libp2p/mplex/dist/src/mplex.js:134:38
    at async MplexStreamMuxer.sink (file:///.../node_modules/@libp2p/mplex/dist/src/mplex.js:133:17) {
  code: 'ERR_MSG_TOO_BIG'
}

alxroyer avatar Aug 11 '22 18:08 alxroyer

For the info, I came up through this while measuring the impact of chunk sizes on transfer rates, which gave me the graph below:

p2p902-2022-08-11a

We can see on this graph that orange dots ([email protected]) stop at 2Mb, while blue dots go up to 10Mb.

alxroyer avatar Aug 11 '22 18:08 alxroyer

You scripts are initializing Mplex with default max message size value, you should set it to something higher: https://github.com/libp2p/js-libp2p-mplex/blob/v1.1.2/src/index.ts#L11

mpetrunic avatar Aug 12 '22 12:08 mpetrunic

@Alexis-ROYER

mpetrunic avatar Aug 12 '22 12:08 mpetrunic

Thanks for the info @mpetrunic.

To compare with the Mplex coming along with [email protected] ([email protected] on my side):

  • I guess it means that the default max message size was different?
  • Or possibly this max message size limit did not exist?

alxroyer avatar Aug 16 '22 07:08 alxroyer

Not sure honestly. maybe something was overriding that limit

mpetrunic avatar Aug 16 '22 09:08 mpetrunic