The RTCIceServer dictionary defines how to connect to a single ICE server (such as a STUN or TURN server). It includes both the URL and the necessary credentials, if any, to connect to the server.
credential Optional
RTCIceServer represents a TURN server.credentialType Optional
RTCIceServer represents a TURN server, this attribute specifies what kind of credential is to be used when connecting. This must be one of the values defined by the RTCIceCredentialType enum. The default is "password".url
RTCIceServer.urls instead. Because many older books and examples still use this, we include it to help developers update their code or make sense of older examples.urlsDOMString or an array of DOMStrings, each specifying a URL which can be used to connect to the server.username Optional
RTCIceServer is a TURN server, then this is the username to use during the authentication process.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.
The RTCIceCredentialType enum specifies values which can be returned by the credentialType property to define what kind of authentication credential is being provided in the RTCIceServer.credential property. This can be one of the values below.
| Constant | Description |
|---|---|
"password" | The credential is a long-term authentication password. See RFC 5389, section 10.2 for further details on this type of credential. |
"token" | The credential is an access token to be used with a third-party authentication system. |
The configuration below establishes two ICE servers. 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: "[email protected]",
credential: "webrtcdemo"
}, {
urls: [
"stun:stun.example.com",
"stun:stun-1.example.com"
]
}]
};
var pc = new RTCPeerConnection(configuration); Once the configuration object has been created, it is passed into the RTCPeerConnection() constructor to use it as the configuration for the new peer connection.
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | Yes | ? | 22 | ? | ? | ? |
credential |
Yes | ? | 22 | ? | ? | ? |
credentialType |
Yes | ? | 47 | ? | ? | ? |
url
|
Yes | ? | 22 | ? | ? | ? |
urls |
Yes | ? | 37 | ? | ? | ? |
username |
Yes | ? | 23 | ? | ? | ? |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | No | Yes | ? | 24 | ? | ? | Yes |
credential |
No | Yes | ? | 24 | ? | ? | Yes |
credentialType |
No | Yes | ? | 47 | ? | ? | Yes |
url
|
No | Yes | ? | 24 | ? | ? | Yes |
urls |
No | Yes | ? | 37 | ? | ? | Yes |
username |
No | Yes | ? | 23 | ? | ? | Yes |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer