Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel send queue is full #895

Open
glitterlip opened this issue Jul 23, 2022 · 2 comments

Comments

@glitterlip
Copy link

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?

@hktalent
Copy link

hktalent commented May 8, 2023

me too
image

@x8BitRain
Copy link

This happens when you send a chunk that is larger than the peerConnection.sctp.maxMessageSize, so your chunks have to be that size or smaller otherwise it will error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants