From 5a91a7aae8c1a0325f50d693b94a33435537315a Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Thu, 3 Sep 2020 13:34:39 +0200 Subject: [PATCH] Reset remote connection if SetRemoteDescription fails. In current versions of pion, SetRemoteDescription fails if ICE is currently gathering. Work around the issue by resetting the connection. --- webclient.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/webclient.go b/webclient.go index 177fb92..df75622 100644 --- a/webclient.go +++ b/webclient.go @@ -463,7 +463,7 @@ func gotOffer(c *webClient, id string, offer webrtc.SessionDescription, renegoti delUpConn(c, id) } - up, _, err := addUpConn(c, id) + up, isnew, err := addUpConn(c, id) if err != nil { return err } @@ -473,6 +473,11 @@ func gotOffer(c *webClient, id string, offer webrtc.SessionDescription, renegoti } err = up.pc.SetRemoteDescription(offer) if err != nil { + if renegotiate && !isnew { + // create a new PC from scratch + log.Printf("SetRemoteDescription(offer): %v", err) + return gotOffer(c, id, offer, false, labels) + } return err }