iceRestart 特性为 RTCOfferOptions dictionary is a Boolean value which, when true , tells the RTCPeerConnection to start ICE renegotiation.

注意: Rather than manually creating and submitting an offer with iceRestart 设为 true , you should consider calling the RTCPeerConnection 方法 restartIce() 代替。

句法

var options = {
  iceRestart: trueOrFalse
};
					

A Boolean value indicating whether or not the RTCPeerConnection should generate new values for the connection's ice-ufrag and ice-pwd values, which will trigger ICE renegotiation on the next message sent to the remote peer.

用法注意事项

RTCPeerConnection object's ICE connection state changes to failed , you should try to trigger an ICE restart . You should ideally do this by calling the RTCPeerConnection 's restartIce() method, if it's available.

Fundamentally, this renegotiation is triggered by generating and using new values for the ICE username fragment ("ufrag")}}

范例

This example shows a handler for the iceconnectionstatechange event. It watches for the ICE connection state to transition to "failed" , which indicates that an ICE restart should be tried in order to attempt to bring the connection back up.

pc.oniceconnectionstatechange = function(evt) {
  if (pc.iceConnectionState === "failed") {
    if (pc.restartIce) {
      pc.restartIce();
    } else {
      pc.createOffer({ iceRestart: true })
      .then(pc.setLocalDescription)
      .then(sendOfferToServer);
    }
  }
}
					

If the state changes to failed , this handler starts by looking to see if the RTCPeerConnection includes the restartIce() method; if it does, we call that to request an ICE restart. Otherwise, we call back to the older technique: we manually create a new offer with iceRestart 设为 true , then that offer is set as the new local description for the connection. After that, the offer is sent to the server by calling a custom function sendOfferToServer() .

规范

规范 状态 注释
WebRTC 1.0: Real-time Communication Between Browsers
The definition of 'RTCOfferOptions.iceRestart' in that specification.
候选推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
iceRestart Chrome 50 Edge ≤79 Firefox 48 IE No Opera ? Safari ? WebView Android 50 Chrome Android 50 Firefox Android 48 Opera Android ? Safari iOS ? Samsung Internet Android 5.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

元数据

  • 最后修改: