AlexxIT/go2rtc · error
err.Error()
Error message
err.Error()
What it means
On GET /api/streams the handler builds a probe consumer and calls stream.AddConsumer(cons); an error here is returned verbatim with HTTP 500. AddConsumer fails when the stream cannot start or negotiate a media with the probe (no working producer, medias mismatch, or start failure).
Solutions
- Verify the stream's producer (source URL) is reachable and working first
- Read the returned error text — it identifies the failed producer/consumer negotiation
- Retry without restrictive medias/candidates query parameters
- Test the source URL directly (e.g. ffprobe) to confirm it streams
Defensive patterns
Strategy: try-catch
Validate before calling
// check the stream has a live producer before probing
const info = await (await fetch(`/api/streams?src=${encodeURIComponent(src)}`)).json();
if (!info || !info.producers || info.producers.length === 0) throw new Error('stream has no producer'); Try / catch
const res = await fetch(`/api/streams?src=${src}&medias=...`);
if (res.status === 500) { const msg = await res.text(); /* msg names AddConsumer failure; check source health */ } Prevention
- Confirm the underlying source (RTSP camera, file) is online before probing
- Avoid over-restrictive medias/candidates query params
- Use the probe endpoint as a health check with retry/backoff
- Check go2rtc logs for producer start errors around the 500
When it happens
Trigger: GET /api/streams?src=X&candidates=... where stream X exists but has no working source, or its producers cannot provide media compatible with the probe consumer's requested medias.
Common situations: Probe endpoint used to test a stream whose upstream RTSP camera is offline; AddConsumer's internal stream.Put/start fails on first consumer; medias= query excludes all available codecs.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/86792efa83d3d114.
Report an issue: GitHub.
Appendix: source
Thrown at internal/streams/api.go:38
if src == "" && r.Method != "POST" {
api.ResponseJSON(w, streams)
return
}
// Not sure about all this API. Should be rewrited...
switch r.Method {
case "GET":
stream := Get(src)
if stream == nil {
http.Error(w, "", http.StatusNotFound)
return
}
cons := probe.Create("probe", query)
if len(cons.Medias) != 0 {
cons.WithRequest(r)
if err := stream.AddConsumer(cons); err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
api.ResponsePrettyJSON(w, stream)
stream.RemoveConsumer(cons)
} else {
api.ResponsePrettyJSON(w, streams[src])
}
case "PUT":
name := query.Get("name")
if name == "" {
name = src
}
if _, err := New(name, query["src"]...); err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)View on GitHub (pinned to c245815e75)