ionorg / ion-sdk-js

ion javascript sdk
MIT License
102 stars 69 forks source link

feat(restartIce) #155

Closed adwpc closed 3 years ago

adwpc commented 3 years ago

Description

add restartIce

Reference issue

Fixes #154 depend on #156

adwpc commented 3 years ago

Reference: https://developer.mozilla.org/en-US/docs/Web/API/RTCOfferOptions/iceRestart

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

lgtm! have you been able to test it? do we require any changes on the sfu side?

adwpc commented 3 years ago

In my test: 1 iceConnectionState changed to "disconnected" in 35s after i switched my network 2 restartIce will trigger onNegotiationNeeded(createOffer-->setLocalDescription-->signal.offer-->setRemoteDescription), signal should support reconnect first(jsonrpc and grpc :() https://stackoverflow.com/questions/13797262/how-to-reconnect-to-websocket-after-close-connection need this one: #156