Skip to content

Commit

Permalink
Fix errors output for webrtc client and server
Browse files Browse the repository at this point in the history
AlexxIT committed Jun 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 734393d commit 31e57c2
Showing 2 changed files with 9 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/webrtc/client.go
Original file line number Diff line number Diff line change
@@ -77,10 +77,15 @@ func go2rtcClient(url string) (core.Producer, error) {
// 2. Create PeerConnection
pc, err := PeerConnection(true)
if err != nil {
log.Error().Err(err).Caller().Send()
return nil, err
}

defer func() {
if err != nil {
_ = pc.Close()
}
}()

// waiter will wait PC error or WS error or nil (connection OK)
var connState core.Waiter
var connMu sync.Mutex
@@ -133,7 +138,8 @@ func go2rtcClient(url string) (core.Producer, error) {
}

if msg.Type != "webrtc/answer" {
return nil, errors.New("wrong answer: " + msg.Type)
err = errors.New("wrong answer: " + msg.String())
return nil, err
}

answer := msg.String()
1 change: 1 addition & 0 deletions internal/webrtc/server.go
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ func outputWebRTC(w http.ResponseWriter, r *http.Request) {
url := r.URL.Query().Get("src")
stream := streams.Get(url)
if stream == nil {
http.Error(w, api.StreamNotFound, http.StatusNotFound)
return
}

0 comments on commit 31e57c2

Please sign in to comment.