diff --git a/internal/webrtc/manager.go b/internal/webrtc/manager.go index 25b9de89..31c439aa 100644 --- a/internal/webrtc/manager.go +++ b/internal/webrtc/manager.go @@ -487,7 +487,7 @@ func (manager *WebRTCManagerCtx) CreatePeer(session types.Session, bitrate int, session.SetWebRTCConnected(peer, true) case webrtc.PeerConnectionStateDisconnected, webrtc.PeerConnectionStateFailed: - connection.Close() + peer.Destroy() case webrtc.PeerConnectionStateClosed: // ensure we only run this once once.Do(func() { diff --git a/internal/webrtc/peer.go b/internal/webrtc/peer.go index 4e26f5d6..91b405c9 100644 --- a/internal/webrtc/peer.go +++ b/internal/webrtc/peer.go @@ -106,11 +106,8 @@ func (peer *WebRTCPeerCtx) Destroy() { peer.mu.Lock() defer peer.mu.Unlock() - if peer.connection != nil { - err := peer.connection.Close() - peer.logger.Err(err).Msg("peer connection destroyed") - peer.connection = nil - } + err := peer.connection.Close() + peer.logger.Err(err).Msg("peer connection destroyed") } func (peer *WebRTCPeerCtx) estimatorReader() {