Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webrtc: on browsers, display error messages from server #3448

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/protocols/webrtc/peer_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
answer, err := co.wr.CreateAnswer(nil)
if err != nil {
if errors.Is(err, webrtc.ErrSenderWithNoCodecs) {
return nil, fmt.Errorf("track codecs are not supported by remote")
return nil, fmt.Errorf("codecs not supported by client")

Check warning on line 314 in internal/protocols/webrtc/peer_connection.go

View check run for this annotation

Codecov / codecov/patch

internal/protocols/webrtc/peer_connection.go#L314

Added line #L314 was not covered by tests
}
return nil, err
}
Expand Down
17 changes: 12 additions & 5 deletions internal/servers/webrtc/publish_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@
})
.then((res) => {
if (res.status !== 204) {
throw new Error('bad status code');
throw new Error(`bad status code ${res.status}`);
}
})
.catch((err) => {
Expand Down Expand Up @@ -464,13 +464,20 @@
body: offer,
})
.then((res) => {
if (res.status !== 201) {
throw new Error('bad status code');
switch (res.status) {
case 201:
break;
case 400:
return res.json().then((e) => { throw new Error(e.error); });
default:
throw new Error(`bad status code ${res.status}`);
}

sessionUrl = new URL(res.headers.get('location'), window.location.href).toString();
return res.text();

return res.text()
.then((answer) => onRemoteAnswer(answer));
})
.then((answer) => onRemoteAnswer(answer))
.catch((err) => {
onError(err.toString(), true);
});
Expand Down
8 changes: 6 additions & 2 deletions internal/servers/webrtc/read_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -426,13 +426,17 @@
break;
case 404:
throw new Error('stream not found');
case 400:
return res.json().then((e) => { throw new Error(e.error); });
default:
throw new Error(`bad status code ${res.status}`);
}

sessionUrl = new URL(res.headers.get('location'), window.location.href).toString();
return res.text();

return res.text()
.then((sdp) => onRemoteAnswer(sdp));
})
.then((sdp) => onRemoteAnswer(sdp))
.catch((err) => {
onError(err.toString());
});
Expand Down
Loading