Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

RTC transport channel closed error on transferring large amount of data #262

Open
AshishSandey opened this issue Oct 13, 2020 · 1 comment
Labels
kind/bug A bug in existing code (including security flaws) status/ready Ready to be worked

Comments

@AshishSandey
Copy link

I am trying to transfer files using libp2p webrtc transport using streaming iterables. I am using it-pipe package for this. In the middle of the transfer I get Transport Error: RTC transport channel closed. I suspect that this is happening due to latency as I can recreate this error only on certain devices (mostly low-end smartphones).
I am using this generator as asynchronous source for file transfer.
async function* fileBufferGenerator(file) { let size = file.size; const bufSize = 2048; for (let i = 0; i < size; i += bufSize) { let fileslice = file.slice(i, Math.min(i + bufSize, size)); let filebuf = await fileslice.arrayBuffer() let bufView = new Uint8Array(filebuf); yield JSON.stringify(Array.from(bufView)) } }
This is the code I am using on the sender end
let source = await fileBufferGenerator(file); pipe( source, stream )
And this one at the receiver end
`
for await (let data of stream.source) {

    let item = JSON.parse(data)
    received += item.length;
    //console.log(data.toString())
    chunks.push(new Uint8Array(item));
    currentProgress = Math.round(received/size*100);

}

`
Can anyone please help me with how to do this properly

@jacobheun
Copy link
Contributor

We should look into the size of packets, webrtc can have a bad time if the packets that get sent over the wire are too big (64kb).

It would be good to add tests around trying to choke the transport, we may need to add a chunk limiter here to prevent sending larger packets.

@jacobheun jacobheun added kind/bug A bug in existing code (including security flaws) status/ready Ready to be worked and removed needs review labels Oct 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug A bug in existing code (including security flaws) status/ready Ready to be worked
Projects
None yet
Development

No branches or pull requests

2 participants