Skip to content
This repository was archived by the owner on Apr 24, 2023. It is now read-only.
This repository was 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

@AshishSandey

Description

@AshishSandey

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugA bug in existing code (including security flaws)status/readyReady to be worked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions