simple-peer
simple-peer copied to clipboard
Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel send queue is full
What version of this package are you using?
9.11.1
What operating system, Node.js, and npm version?
node v16.15.0
npm 8.5.5
macOs 12.4
What happened?
I am using this package to send files.
When file size is small everything is ok.
But when I send a 240Mb file, after 28mb was received ,an Unhandled Rejection (OperationError): Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel send queue is full
error happened.
Then I change the code to
while (offset < filesize) {
const chunk = await readChunk(offset)
if (peer._channel.bufferedAmount >= peer._channel.bufferedAmountLowThreshold) {
peer._channel.onBufferedAmountLow = () => {
peer.send(chunk);
peer._channel.onBufferedAmountLow = null;
};
} else {
peer.send(chunk);
}
}
this time it just stuck forever after transfer >80Mb data.
while (offset < filesize) {
const chunk = await readChunk(offset)
if (peer._channel.bufferedAmount >= peer._channel.bufferedAmountLowThreshold) {
await new Promise((resolve) => {
setTimeout(() => {
peer.send(chunk);
resolve();
}, 50);
});
} else {
peer.send(chunk);
}
}
use promise and settimeout fix the problem ,but I have to wait and dont know 50ms is the proper duration
What did you expect to happen? how to deal with `RTCDataChannel send queue is full``
Are you willing to submit a pull request to fix this bug?
me too