RTCIceTransport: getLocalCandidates() method

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

The getLocalCandidates() method of the RTCIceTransport interface returns an array of RTCIceCandidate objects, one for each of the candidates that have been gathered by the local device during the current ICE agent session.

The local candidates are placed in this list by the ICE agent prior to being delivered to the local client's code in an icecandidate event so that the client can forward the candidates to the remote peer.

Syntax

js
getLocalCandidates()

Parameters

None.

Return value

A JavaScript Array containing one RTCIceCandidate object for each candidate that has been identified so far during the ICE candidate gathering session.

You can't correlate these local candidates with matching remote candidates. To find the best match found so far, call RTCIceTransport.getSelectedCandidatePair().

Examples

This simple example gets the local candidate list from the RTCIceTransport for the first RTCRtpSender on the RTCPeerConnection, then outputs to the console all of the candidates in the list.

js
const localCandidates = pc
  .getSenders()[0]
  .transport.iceTransport.getLocalCandidates();

localCandidates.forEach((candidate, index) => {
  console.log(`Candidate ${index}: ${candidate.candidate}`);
});

Specifications

Specification
WebRTC: Real-Time Communication in Browsers
# dom-rtcicetransport-getlocalcandidates

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
getLocalCandidates
Chrome – Full support
Chrome 75 (Release date: 2019-06-04)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – Full support
Opera 62 (Release date: 2019-06-27)
footnote Full support
Safari – No support
Safari
footnote No support
Chrome Android – Full support
Chrome Android 75 (Release date: 2019-06-04)
footnote Full support
Firefox for Android – No support
Firefox for Android
footnote No support
Opera Android – Full support
Opera Android 54 (Release date: 2019-10-18)
footnote Full support
Safari on iOS – No support
Safari on iOS
footnote No support
Samsung Internet – Full support
Samsung Internet 11 (Release date: 2019-12-05)
footnote Full support
WebView Android – Full support
WebView Android 75 (Release date: 2019-06-04)
footnote Full support
WebView on iOS – No support
WebView on iOS
footnote No support

Legend

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

Full support
Full support
No support
No support