RTCDataChannel: closing event

Baseline 2025
Newly available

Since October 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

The closing event is sent to an RTCDataChannel just before the channel begins the process of shutting down its underlying data transport.

This event is not cancelable and does not bubble.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

js
addEventListener("closing", (event) => { })

onclosing = (event) => { }

Event type

A generic Event.

Description

While the closing event is sent to the channel just before beginning to close the channel's data transport, the close event is sent once the closing process is complete.

Examples

This example updates a connection status interface when the closing event arrives.

First, an example using addEventListener():

js
dataChannel.addEventListener("closing", (ev) => {
  myConnectionStatus.icon = closingIcon;
  myConnectionStatus.text = "Connection closing";
});

You can also set the onclosing event handler property directly:

js
pc.onclosing = (ev) => {
  myConnectionStatus.icon = closingIcon;
  myConnectionStatus.text = "Connection closing";
};

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# event-datachannel-closing
WebRTC: Real-Time Communication in Browsers
# dom-rtcdatachannel-onclosing

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
closing event
Chrome – Full support
Chrome 81 (Release date: 2020-04-07)
footnote Full support
Edge – Full support
Edge 81 (Release date: 2020-04-13)
footnote Full support
Firefox – Full support
Firefox 144 (Release date: 2025-10-14)
footnote Full support
Opera – Full support
Opera 68 (Release date: 2020-04-22)
footnote Full support
Safari – Full support
Safari 15.4 (Release date: 2022-03-14)
footnote Full support
Chrome Android – Full support
Chrome Android 81 (Release date: 2020-04-07)
footnote Full support
Firefox for Android – Full support
Firefox for Android 144 (Release date: 2025-10-14)
footnote Full support
Opera Android – Full support
Opera Android 58 (Release date: 2020-05-13)
footnote Full support
Safari on iOS – Full support
Safari on iOS 15.4 (Release date: 2022-03-14)
footnote Full support
Samsung Internet – Full support
Samsung Internet 13 (Release date: 2020-12-02)
footnote Full support
WebView Android – Full support
WebView Android 81 (Release date: 2020-04-07)
footnote Full support
WebView on iOS – Full support
WebView on iOS 15.4 (Release date: 2022-03-14)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also