{{APIRef("WebRTC")}}{{draft}}
The RTCConfiguration
dictionary is used to provide configuration options for an {{domxref("RTCPeerConnection")}}. It may be passed into the constructor when instantiating a connection, or used with the {{domxref("RTCPeerConnection.getConfiguration()")}} and {{domxref("RTCPeerConnection.setConfiguration()")}} methods, which allow inspecting and changing the configuration while a connection is established.
The options include ICE server and transport settings and identity information.
Properties
- iceServers
- An array of RTCIceServer objects, each describing one server which may be used by the ICE agent; these are typically STUN and/or TURN servers.
- iceTransportPolicy
- The current ICE transport policy; this must be one of the values from the
RTCIceTransportPolicy
enum. If this isn't specified,"all"
is assumed.
RTCIceServer Properties
Name | Type | Description |
---|---|---|
urls |
{{domxref("DOMString")}}, {{jsxref("Array")}} | Either a string specifying a single STUN or TURN server's URI to use, or an array of strings specifying multiple URIs for servers with multiple addresses. |
username |
{{domxref("DOMString")}} | An account username (optional) |
credential |
{{domxref("DOMString")}} | The password associated with username, if given (optional) |
Avoid specifying an unnecessarily large number of URLs in the urls
property; the startup time for your connection will go up substantially. Every server in the list will be contacted and tried out before one is selected to be used for negotiation.
Older versions of the WebRTC specification included an url
property instead of urls
; this was changed in order to let you specify multiple addresses for each server in the list, as shown in the example below.
Constants
{{page("/en-US/docs/Web/API/RTCPeerConnection", "RTCIceTransportPolicy enum", 0, 1)}}
Example
var configuration = { iceServers: [{ urls: "stun:stun.services.mozilla.com", username: "[email protected]", credential: "webrtcdemo" }, { urls: ["stun:stun.example.com", "stun:stun-1.example.com"] }] }; var pc = new RTCPeerConnection(configuration);