This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
A bufferedamountlow event is sent to an RTCDataChannel when the number of bytes currently in the outbound data transfer buffer (bufferedAmount) falls from above to below or equal the threshold specified in bufferedAmountLowThreshold.
This event is not cancelable and does not bubble.
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("bufferedamountlow", (event) => { })
onbufferedamountlow = (event) => { }
A generic Event.
This example sets up a handler for bufferedamountlow to request more data any time the data channel's buffer falls below the number of bytes specified by bufferedAmountLowThreshold, which we have set to 65536. In other words, we'll try to keep at least 64kB of data in the buffer, reading 64kB at a time from the source.
let pc = new RTCPeerConnection();
let dc = pc.createDataChannel("SendFile");
// Replace with your own source object, such as a file handle
let source = null;
dc.bufferedAmountLowThreshold = 65536;
pc.addEventListener(
"bufferedamountlow",
(ev) => {
if (source.position <= source.length) {
dc.send(source.readFile(65536));
}
},
false,
);
After creating the RTCPeerConnection, this calls RTCPeerConnection.createDataChannel() to create the data channel. Then a listener is created for bufferedamountlow to refill the incoming data buffer any time its contents fall below 65536 bytes.
You can also set up a listener for bufferedamountlow using its event handler property, onbufferedamountlow:
pc.onbufferedamountlow = (ev) => {
if (source.position <= source.length) {
dc.send(source.readFile(65536));
}
};
| Specification |
|---|
| WebRTC: Real-Time Communication in Browsers> # event-datachannel-bufferedamountlow> |
| WebRTC: Real-Time Communication in Browsers> # dom-rtcdatachannel-onbufferedamountlow> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
bufferedamountlow_event |
57The default forrtcpMuxPolicy is require. |
79The default forrtcpMuxPolicy is require. |
44 | 44The default forrtcpMuxPolicy is require. |
11 | 57The default forrtcpMuxPolicy is require. |
44 | 43The default forrtcpMuxPolicy is require. |
11 | 7.0The default forrtcpMuxPolicy is require. |
57The default forrtcpMuxPolicy is require. |
11 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/bufferedamountlow_event