diff --git a/peerconnection.go b/peerconnection.go index aae87ef0082..ff5bcf54db3 100644 --- a/peerconnection.go +++ b/peerconnection.go @@ -2218,7 +2218,7 @@ func (pc *PeerConnection) close(shouldGracefullyClose bool) error { // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #6) if pc.sctpTransport != nil { - closeErrs = append(closeErrs, pc.sctpTransport.Stop()) + closeErrs = append(closeErrs, pc.sctpTransport.Abort("")) } // https://www.w3.org/TR/webrtc/#dom-rtcpeerconnection-close (step #7) diff --git a/sctptransport.go b/sctptransport.go index 6d387839b22..ec93b6dab23 100644 --- a/sctptransport.go +++ b/sctptransport.go @@ -146,6 +146,21 @@ func (r *SCTPTransport) Start(SCTPCapabilities) error { return nil } +// Abort send the abort message and stops the SCTPTransport +func (r *SCTPTransport) Abort(reason string) error { + r.lock.Lock() + defer r.lock.Unlock() + if r.sctpAssociation == nil { + return nil + } + r.sctpAssociation.Abort(reason) + + r.sctpAssociation = nil + r.state = SCTPTransportStateClosed + + return nil +} + // Stop send the abort message and stops the SCTPTransport func (r *SCTPTransport) Stop() error { r.lock.Lock() @@ -153,7 +168,6 @@ func (r *SCTPTransport) Stop() error { if r.sctpAssociation == nil { return nil } - r.sctpAssociation.Abort("") err := r.sctpAssociation.Close() if err != nil { return err