RTCIceCandidate: candidate property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2017.

The read-only property candidate on the RTCIceCandidate interface returns a string describing the candidate in detail. Most of the other properties of RTCIceCandidate are actually extracted from this string.

This property can be configured using the candidate property of the object passed into the RTCIceCandidate() constructor or RTCPeerConnection.addIceCandidate().

Value

A string describing the properties of the candidate, taken directly from the SDP attribute "candidate". The candidate string specifies the network connectivity information for the candidate. If the candidate is an empty string (""), the end of the candidate list has been reached; this candidate is known as the "end-of-candidates" marker.

The syntax of the candidate string is described in RFC 5245, section 15.1. For an a-line (attribute line) that looks like this:

a=candidate:4234997325 1 udp 2043278322 192.0.2.172 44323 typ host

the corresponding candidate string's value will be: "candidate:4234997325 1 udp 2043278322 192.0.2.172 44323 typ host".

The user agent always prefers candidates with the highest priority, all else being equal. In the example above, the priority is 2043278322. The attributes are all separated by a single space character, and are in a specific order. The complete list of attributes for this example candidate is:

Examples

In this example, we see a function which receives as input an SDP string containing an ICE candidate received from the remote peer during the signaling process.

js
function handleNewIceCandidate(candidateSDP) {
  const candidateObj = new RTCIceCandidate(candidateSDP);

  myPeerConnection.addIceCandidate(candidateObj).catch({
    /* handle the error thrown by addIceCandidate() */
  });
}

The handleNewIceCandidate() function shown here passes the received candidate's SDP text into RTCIceCandidate() to receive an RTCIceCandidate object in return, which represents the candidate.

The new candidate is then passed into RTCPeerConnection.addIceCandidate() to add the candidate to the list of candidates for WebRTC to consider using for the connection being established.

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# dom-rtcicecandidate-candidate

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
candidate
Chrome – Full support
Chrome 23 (Release date: 2012-11-06)
footnote Full support
Edge – Full support
Edge 15 (Release date: 2017-04-05)
footnote Full support
Firefox – Full support
Firefox 22 (Release date: 2013-06-25)
footnote
footnote Before Firefox 126, the property was not read-only.
Opera – Full support
Opera 15 (Release date: 2013-07-02)
footnote Full support
Safari – Full support
Safari 11 (Release date: 2017-09-19)
footnote Full support
Chrome Android – Full support
Chrome Android 25 (Release date: 2013-02-27)
footnote Full support
Firefox for Android – Full support
Firefox for Android 24 (Release date: 2013-09-17)
footnote
footnote Before Firefox 126, the property was not read-only.
Opera Android – Full support
Opera Android 14 (Release date: 2013-05-21)
footnote Full support
Safari on iOS – Full support
Safari on iOS 11 (Release date: 2017-09-19)
footnote Full support
Samsung Internet – Full support
Samsung Internet 1.5 (Release date: 2013-09-25)
footnote Full support
WebView Android – Full support
WebView Android 4.4 (Release date: 2013-12-09)
footnote Full support
WebView on iOS – Full support
WebView on iOS 11 (Release date: 2017-09-19)
footnote Full support

Legend

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

Full support
Full support
See implementation notes.