You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.
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
The text was updated successfully, but these errors were encountered:
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) {
`
Can anyone please help me with how to do this properly
The text was updated successfully, but these errors were encountered: