Ostap Maliuvanchuk
Ostap Maliuvanchuk

Reputation: 1175

How to resume WebRTC call when one TURN server goes down

I have multiple turn servers in my WebRTC config:

  iceServers: [
    {
      urls: 'turn:turn.example.com',
      username: 'username',
      credential: 'pass'
    },
    {
      urls: 'turn:turn2.example.com',
      username: 'username',
      credential: 'pass'
    }
  ]

When I start WebRTC call and then bring down turn.example.com the communication freezes. WebRTC does not seem to automatically pick up new ICE candidate and resume the call.

Is there a way to resume/reestablish communication using second ICE server?

Upvotes: 4

Views: 780

Answers (1)

Taylor Brandstetter
Taylor Brandstetter

Reputation: 3623

You should be able to use an ICE restart to gather fresh TURN candidates. To do an ICE restart, you need to perform another offer/answer exchange that changes the ICE username fragments and passwords. To trigger this, you can simply call:

pc.createOffer({iceRestart: true})

Upvotes: 4

Related Questions