RTCConfiguration.iceTransportPolicy

The WebRTC Device API dictionary RTCConfiguration's iceTransportPolicy property is a string indicating the transport selection policy the ICE agent should use during negotiation of connections. Its value must come from the RTCIceTransportPolicy enumerated type.

If this property isn't included in the RTCConfiguration, the default value, all, is used.

Syntax

let rtcConfiguration = {
  iceTransportPolicy: policy
};

rtcConfiguration.iceTransportPolicy = policy;
let policy = rtcConfiguration.iceTransportPolicy;

Value

A DOMString which indicates what ICE candidate policy the ICE agent should use during the negotiation process, per the JSEP standard. The permitted values are:

all
The ICE agent is permitted to use any kind of candidate, including both local and relay candidates. The agent—or the browser itself—may still perform some form of IP filtering on the incoming candidates for reasons including privacy and security, as well as to simply limit the number of candidates. This is the default.
relay

The ICE agent only considers media relay candidates when evaluating candidates. This includes, for example, those candidates relayed by a STUN or TURN server.

This can be used to prevent the remote endpoint from receiving the user's IP addresses, which may be important in some security situations. For example, in a video calling application, the app may want to prevent unknown callers from learning the callee's IP addresses until the callee has agreed to receive the call.

Examples

In this example, a new connection is configured to only accept relay candidates.

let config = {
  iceServers: [
    {
      urls: [ "stun:stun.example.com" ]
    },
  ],
  iceTransportPolicy: "relay"
};

let pc = new RTCPeerConnection(config);

Specifications

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

Browser compatibility

No compatibility data found. Please contribute data for "api.RTCCandidate.iceTransportPolicy" (depth: 1) to the MDN compatibility data repository.