Home

createDataChannel

createDataChannel is a method of the WebRTC RTCPeerConnection API that creates a data channel for bidirectional data transfer between peers. It returns an RTCDataChannel immediately and begins the in-band signaling process to establish the channel over the DTLS-SCTP transport. The remote peer typically receives the channel via the ondatachannel event when the channel is created.

Usage and parameters: The method takes a mandatory label string that identifies the data channel, and an

Behavior and data transfer: The returned RTCDataChannel exposes a readyState (connecting, open, closing, closed) and supports

Negotiation model: By default, data channels are negotiated in-band as part of the WebRTC signaling flow, with

Applications and considerations: Data channels are suitable for low-latency messaging, file transfer, and real-time collaboration. All

optional
dataChannelDict
(DataChannelInit)
object
that
configures
the
channel.
The
DataChannelInit
dictionary
can
specify
ordered
(default
true),
maxPacketLifeTime
(for
unreliable
delivery,
in
milliseconds),
maxRetransmits
(alternative
to
maxPacketLifeTime
for
unreliable
delivery),
protocol
(application
protocol
string),
negotiated
(whether
to
negotiate
out
of
band),
and
id
(channel
identifier
used
when
negotiated
is
true).
It
is
not
valid
to
set
both
maxPacketLifeTime
and
maxRetransmits
at
the
same
time.
the
send
method
to
transmit
data.
Data
can
be
text
strings
or
binary
data
such
as
ArrayBuffer,
TypedArray,
or
Blob.
The
channel
fires
events
such
as
open,
message,
close,
and
error
to
signal
state
changes
and
incoming
data.
the
remote
peer
creating
a
corresponding
channel
or
receiving
it
via
ondatachannel.
If
negotiated
is
set
to
true,
both
peers
must
explicitly
create
the
channel
with
a
matching
id,
using
out-of-band
signaling
to
agree
on
the
channel.
data
is
transmitted
over
the
secured
DTLS
transport,
with
SCTP
providing
reliability
options
as
configured.
Browser
support
is
broad
in
modern
environments,
with
some
differences
in
options
across
implementations.