1

I try to reconnect after network offline. I success to re connecting to call if the network fail in receiver side. But i don't success to do it if network fail in the caller side.

I try to re -init the web WebRTC client , it's don't work. Also try to create new offer , it's also don't work.

Do anyone know how to handle re connect in android with WebRTC?

blay
  • 464
  • 9
  • 23

1 Answers1

0

My case was slightly different since I ran into this issue while trying to implement WIFI > DATA network connection transition but I'm confident that this should work for you as well.

The solution for me was to recreate the offer and add a new constraint IceRestart in MediaConstraints and set it to true:

val mediaConstraint = MediaConstraints().apply {
    mandatory.add(MediaConstraints.KeyValuePair("IceRestart", "true"))
}

Then you just add the param in createOffer() (which you should probably have already) like so:

peerConnection.createOffer(object : SdpObserver() {
    override fun onCreateSuccess(p0: SessionDescription?) {
        // normal implementation
    }
},mediaConstraint)

Hope it helps :)

gmartinsnull
  • 1,075
  • 1
  • 12
  • 11
  • thanks for the answer. Just want to clarify, when you first establish the connection the Offer will not contain the above constraint? only upon experiencing disconnection while generating a new Offer? – Tomer Petel May 17 '22 at 09:02