webrtc / samples

WebRTC Web demos and samples
https://webrtc.github.io/samples
BSD 3-Clause "New" or "Revised" License
13.86k stars 5.7k forks source link

filetransfer example doesn't call onbufferedamountlow #1669

Open sysescool opened 1 month ago

sysescool commented 1 month ago

Please read first!

Please use discuss-webrtc for general technical discussions and questions. If you have found an issue/bug with the native libwebrtc SDK or a browser's behaviour around WebRTC please create an issue in the relevant bug tracker. You can find more information on how to submit a bug and do so in the right place here

Note: If the checkboxes above are not checked (which you do after the issue is posted), the issue will be closed.

Browser affected

One Side: Chrome Version 119.0.6045.159 (Official Build) (64-bit) Another Side: Edge Version 126.0.2592.87 (Official Build) (64-bit)

Description

The file transfer example code is below: https://github.com/webrtc/samples/blob/gh-pages/src/content/datachannel/filetransfer/js/main.js However, it only run on the local, send file from local to local by DataChannel.

Steps to reproduce

Make a Signal server, and a STUN/TURN server. Use the code about this file transfer example but to real peer-to-peer connection through Internet. send a large file(e.g. 300M).

Expected results

I notice that: https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/bufferedamountlow_event we could add call onbufferedamountlow to this example, so that the developers will understand and quickly apply it. And developers will not see below error.

Actual results

You will see the error in the Console:

Uncaught DOMException: Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel send queue is full
    at RTCDataChannel.send (https://webrtc.github.io/adapter/adapter-latest.js:1244:34)
    at fileReader.onload (https://xxxxxx/js/main.js:168:6)
        send                  @adapter-latest.js:1244
        fileReader.onload     @main.js:168
        load(异步)
        sendData              @main.js:166
        sendfile              @main.js:140

Assign

Please assign me. I am working with webrtc recently and handling this error.

sysescool commented 1 month ago

another question: If the file is huge, how is it added to the receiveBuffer?

fippo commented 1 month ago

872 mentions this but was closed for no good reason. I wonder if the strategy from

https://github.com/otalk/filetransfer/blob/master/filetransfer.js#L28 still works but it has been eight years...

sysescool commented 1 month ago

872 mentions this but was closed for no good reason. I wonder if the strategy from https://github.com/otalk/filetransfer/blob/master/filetransfer.js#L28 still works but it has been eight years...

I don't know why ErikHellman said: "Also ,there seems to be some problems with that event at the moment. " in this link #872. And what exactly is the problem ErikHellman is talking about?

However, in reality, if you do not utilize this event in a practical scenario, the mentioned error will be triggered once the buffer queue is full and you proceed with the transmission.

I'm not particularly familiar with javascript, and my implementation is slightly different from yours. You should test whether it works.