The RTCConfiguration dictionary's iceServers property is an array of RTCIceServer objects, each of which describes a single STUN or TURN server to use for negotiation purposes.


let rtcConfiguration = {
  iceServers: [ iceServer1... ]

let rtcConfiguration.iceServers = [ iceServer1... ];


An array of zero or more RTCIceServer objects, each of which describes one STUN or TURN server for the ICE agent to use during the connection's negotiation. Each object must at least have an urls property, which is an array of one or more strings, each providing one server's URL.

If the array is empty, or if the iceServers option isn't specified, the ICE agent will negotiate without the use of any servers, which will limit the connection to local peers.


How the list of servers you provide is used is up to the implementation of the user agent. While it can be useful to provide a second server as a fallback in case the first is offline, listing too many servers can delay the user's connection being established, depending on the network's performance and how many servers get used for negotiation before a connection is established.

If the list of servers is changed while a connection is already active by calling the RTCPeerConnection method setConfiguration(), no immediate effect occurs. However, the new list of servers is used for any future renegotiation, such as while handling an ICE restart.


The configuration below opens a new peer connection, specifying two servers for the ICE agent to use for negotiation. The first one, stun:stun.services.mozilla.com, requires authentication, so the username and password are provided. The second server has two URLs: stun:stun.example.com and stun:stun-1.example.com.

var configuration = { iceServers: [{
                          urls: "stun:stun.services.mozilla.com",
                          username: "louis@mozilla.com",
                          credential: "webrtcdemo"
                      }, {
                          urls: ["stun:stun.example.com", "stun:stun-1.example.com"]

var pc = new RTCPeerConnection(configuration);


WebRTC 1.0: Real-Time Communication Between Browsers (WebRTC 1.0)
# dom-rtcconfiguration-iceservers

Browser compatibility

BCD tables only load in the browser

See also