This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The RTCDataChannel interface represents a network channel which can be used for bidirectional peer-to-peer transfers of arbitrary data. Every data channel is associated with an RTCPeerConnection, and each peer connection can have up to a theoretical maximum of 65,534 data channels (the actual limit may vary from browser to browser).

To create a data channel and ask a remote peer to join you, call the RTCPeerConnection's createDataChannel() method. The peer being invited to exchange data receives a datachannel event (which has type RTCDataChannelEvent) to let it know the data channel has been added to the connection.

Properties

Also inherits properties from: EventTarget

binaryType
The property binaryType on the RTCDataChannel interface is a DOMString which specifies the type of JavaScript object which should be used to represent binary data received on the RTCDataChannel. Values allowed by the WebSocket.binaryType property are also permitted here: "blob" if Blob objects are being used or "arraybuffer" if ArrayBuffer objects are being used. The default is "blob".
bufferedAmount Read only
The read-only RTCDataChannel property bufferedAmount returns the number of bytes of data currently queued to be sent over the data channel.
bufferedAmountLowThreshold
The RTCDataChannel property bufferedAmountLowThreshold is used to specify the number of bytes of buffered outgoing data that is considered "low." The default value is 0.
id Read only
The read-only RTCDataChannel property id returns an ID number (between 0 and 65,534) which uniquely identifies the RTCDataChannel.
label Read only
The read-only RTCDataChannel property label returns a DOMString containing a name describing the data channel. These labels are not required to be unique.
maxPacketLifeTime Read only
The read-only RTCDataChannel property maxPacketLifeTime returns the amount of time, in milliseconds, the browser is allowed to take to attempt to transmit a message, as set when the data channel was created, or null.
maxRetransmits Read only
The read-only RTCDataChannel property maxRetransmits returns the maximum number of times the browser should try to transmit a message before giving up when in unordered mode, as set when the data channel was created, or null, which indicates that there is no maximum.
negotiated Read only
The read-only RTCDataChannel property negotiated indicates whether the RTCDataChannel's connection was negotiated by the Web app (true) or by the WebRTC layer (false). The default is false.
ordered Read only
The read-only RTCDataChannel property ordered indicates whether or not the data channel guarantees in-order delivery of messages; the default is true, which indicates that the data channel is indeed ordered.
protocol Read only
The read-only RTCDataChannel property protocol returns a DOMString containing the name of the subprotocol in use. If no protocol was specified when the data channel was created, then this property's value is "" (the empty string).
readyState Read only
The read-only RTCDataChannel property readyState returns an enum of type RTCDataChannelState which indicates the state of the data channel's underlying data connection.
reliable Read only
The read-only RTCDataChannel property reliable indicates whether or not the data channel is reliable.
stream Read only
The deprecated (and never part of the official specification) read-only RTCDataChannel property stream returns an ID number (between 0 and 65,535) which uniquely identifies the RTCDataChannel.

Event handlers

Also inherits event handlers from: EventTarget

onbufferedamountlow
The RTCDataChannel.onbufferedamountlow property is an EventHandler which specifies a function the browser calls when the bufferedamountlow event is sent to the RTCDataChannel. This event, which is represented by a simple Event object, is sent when the amount of data buffered to be sent falls to or below the threshold specified by the channel's bufferedAmountLowThreshold.
onclose
The RTCDataChannel.onclose property is an EventHandler which specifies a function to be called by the browser when the close event is received by the RTCDataChannel. This is a simple Event which indicates that the data channel has closed down.
onerror
The RTCDataChannel.onerror property is an EventHandler which specifies a function to be called when the error event is received. When an error occurs on the data channel, the function receives as input an ErrorEvent object describing the error which occurred.
onmessage
The RTCDataChannel.onmessage property stores an EventHandler which specifies a function to be called when the message event is fired on the channel. This event is represented by the MessageEvent interface. This event is sent to the channel when a message is received from the other peer.
onopen
The RTCDataChannel.onopen property is an EventHandler which specifies a function to be called when the open event is fired; this is a simple Event which is sent when the data channel's underlying data transport—the link over which the RTCDataChannel's messages flow—is established or re-established.

Methods

Also inherits methods from: EventTarget

close()
The RTCDataChannel.close() method closes the RTCDataChannel. Either peer is permitted to call this method to initiate closure of the channel.
send()
The send() method of the RTCDataChannel interface sends data across the data channel to the remote peer.

Data format

The underlying data format is defined by the IEEE draft specification draft-ietf-mmusic-sctp-sdp. The current format specifies its protocol as either "UDP/DTLS/SCTP" (UDP carrying DTLS carrying SCTP) or "TCP/DTLS/SCTP" (TCP carrying DTLS carrying SCTP). Older browsers may only specify "DTLS/SCTP".

Example

var pc = new RTCPeerConnection();
var dc = pc.createDataChannel("my channel");

dc.onmessage = function (event) {
  console.log("received: " + event.data);
};

dc.onopen = function () {
  console.log("datachannel open");
};

dc.onclose = function () {
  console.log("datachannel close");
};

Specifications

Specification Status Comment
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCDataChannel' in that specification.
Candidate Recommendation Initial specification.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
Experimental
Chrome Full support YesEdge ? Firefox Full support 24
Full support 24
No support 22 — 60
Alternate Name
Alternate Name Uses the non-standard name: DataChannel
IE No support NoOpera Full support YesSafari ? WebView Android Full support 4.4Chrome Android Full support 29Edge Mobile ? Firefox Android Full support 24
Full support 24
No support 22 — 60
Alternate Name
Alternate Name Uses the non-standard name: DataChannel
Opera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes
binaryType
Experimental
Chrome Full support YesEdge ? Firefox Full support 22IE No support NoOpera Full support YesSafari ? WebView Android Full support 4.4Chrome Android Full support 29Edge Mobile ? Firefox Android Full support 22Opera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support Yes
bufferedAmount
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
bufferedAmountLowThreshold
Experimental
Chrome Full support 56Edge ? Firefox Full support YesIE No support NoOpera Full support 43Safari Full support YesWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
closeChrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
id
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
label
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
maxPacketLifeTime
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
maxRetransmits
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
negotiated
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
ordered
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
protocol
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
onbufferedamountlow
Experimental
Chrome Full support 57
Notes
Full support 57
Notes
Notes The default for rtcpMuxPolicy is require.
Edge ? Firefox Full support YesIE ? Opera Full support 44
Notes
Full support 44
Notes
Notes The default for rtcpMuxPolicy is require.
Safari Full support YesWebView Android Full support 57
Notes
Full support 57
Notes
Notes The default for rtcpMuxPolicy is require.
Chrome Android Full support 57
Notes
Full support 57
Notes
Notes The default for rtcpMuxPolicy is require.
Edge Mobile ? Firefox Android ? Opera Android Full support 44
Notes
Full support 44
Notes
Notes The default for rtcpMuxPolicy is require.
Safari iOS ? Samsung Internet Android Full support 7.0
onclose
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
onerror
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
onmessage
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
onopen
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
priorityChrome ? Edge ? Firefox ? IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android ? Opera Android ? Safari iOS ? Samsung Internet Android ?
readyState
Experimental
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
reliable
Deprecated
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
Support for sctp-sdp-21 formatChrome Full support 58Edge ? Firefox Full support 63IE No support NoOpera ? Safari No support NoWebView Android Full support 58Chrome Android Full support 58Edge Mobile ? Firefox Android Full support 63Opera Android ? Safari iOS ? Samsung Internet Android ?
sendChrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0
stream
DeprecatedNon-standard
Chrome Full support 56Edge ? Firefox No support NoIE No support NoOpera Full support 43Safari No support NoWebView Android Full support 56Chrome Android Full support 56Edge Mobile ? Firefox Android No support NoOpera Android Full support 43Safari iOS ? Samsung Internet Android Full support 6.0

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.
See implementation notes.
See implementation notes.
Uses a non-standard name.
Uses a non-standard name.

See also

Document Tags and Contributors

Contributors to this page: ExE-Boss, Sheppy, fscholz, jpmedley, vonagam, bemasc, kscarfone, teoli, m0ppers, tOkeshu
Last updated by: ExE-Boss,