fix(webrtc): handle client connection errors gracefully (#2173)
- add deferred function to close the client connection on error - ensure proper cleanup for all client functions
This commit is contained in:
committed by
GitHub
parent
4a65f06864
commit
046096826b
@@ -190,6 +190,12 @@ func whepClient(url string) (core.Producer, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
_ = pc.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
prod := webrtc.NewConn(pc)
|
prod := webrtc.NewConn(pc)
|
||||||
prod.Mode = core.ModeActiveProducer
|
prod.Mode = core.ModeActiveProducer
|
||||||
prod.Protocol = "http"
|
prod.Protocol = "http"
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ func crealityClient(url string) (core.Producer, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
_ = pc.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
prod := webrtc.NewConn(pc)
|
prod := webrtc.NewConn(pc)
|
||||||
prod.FormatName = "webrtc/creality"
|
prod.FormatName = "webrtc/creality"
|
||||||
prod.Mode = core.ModeActiveProducer
|
prod.Mode = core.ModeActiveProducer
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ func kinesisClient(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
_ = pc.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// protect from sending ICE candidate before Offer
|
// protect from sending ICE candidate before Offer
|
||||||
var sendOffer core.Waiter
|
var sendOffer core.Waiter
|
||||||
|
|
||||||
|
|||||||
@@ -192,6 +192,12 @@ func milestoneClient(rawURL string, query url.Values) (core.Producer, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
_ = pc.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
prod := webrtc.NewConn(pc)
|
prod := webrtc.NewConn(pc)
|
||||||
prod.FormatName = "webrtc/milestone"
|
prod.FormatName = "webrtc/milestone"
|
||||||
prod.Mode = core.ModeActiveProducer
|
prod.Mode = core.ModeActiveProducer
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ func openIPCClient(rawURL string, query url.Values) (core.Producer, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if err != nil {
|
||||||
|
_ = pc.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
// protect from sending ICE candidate before Offer
|
// protect from sending ICE candidate before Offer
|
||||||
var sendAnswer core.Waiter
|
var sendAnswer core.Waiter
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user