Skip to content

Commit

Permalink
Fix errors output for webrtc client and server
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Jun 16, 2024
1 parent 734393d commit 31e57c2
Show file tree
Hide file tree
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
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions internal/webrtc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 31e57c2

Please sign in to comment.