{"record":{"id":"6ef3f45e6e36a69b","repo":"AlexxIT/go2rtc","slug":"stream-not-found-6ef3f4","errorCode":null,"errorMessage":"stream not found","messagePattern":"stream not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"internal/rtmp/rtmp.go","lineNumber":158,"sourceCode":"\t\t_, err = cons.WriteTo(wr)\n\t}\n\n\treturn cons, run, nil\n}\n\nfunc apiHandle(w http.ResponseWriter, r *http.Request) {\n\tif r.Method != \"POST\" {\n\t\toutputFLV(w, r)\n\t} else {\n\t\tinputFLV(w, r)\n\t}\n}\n\nfunc outputFLV(w http.ResponseWriter, r *http.Request) {\n\tsrc := r.URL.Query().Get(\"src\")\n\tstream := streams.Get(src)\n\tif stream == nil {\n\t\thttp.Error(w, api.StreamNotFound, http.StatusNotFound)\n\t\treturn\n\t}\n\n\tcons := flv.NewConsumer()\n\tcons.WithRequest(r)\n\n\tif err := stream.AddConsumer(cons); err != nil {\n\t\tlog.Error().Err(err).Caller().Send()\n\t\treturn\n\t}\n\n\th := w.Header()\n\th.Set(\"Content-Type\", \"video/x-flv\")\n\n\t_, _ = cons.WriteTo(w)\n\n\tstream.RemoveConsumer(cons)\n}","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/rtmp/rtmp.go#L140-L176","documentation":"outputFLV serves an FLV stream by looking it up with streams.Get(src); when no stream is registered under that name the handler returns the api.StreamNotFound message with HTTP 404. The library throws this because it cannot output a stream that does not exist in its in-memory stream registry.","triggerScenarios":"HTTP GET to the FLV output endpoint with a `src` query parameter naming a stream that was never created, was removed, or is spelled differently from the configured stream name.","commonSituations":"Typo in the src name; stream defined in a different config section (streams vs mp4/rtsp naming); stream not yet started so Get returns nil; consumer requests a stream after go2rtc restart wiped dynamic streams.","solutions":["Check that a stream with exactly that name exists in the streams config section","Use the /api/streams endpoint to list actual stream names","Create the stream first (config or POST /api/streams?src=...) before consuming","Fix the URL's src query parameter spelling/case"],"exampleFix":"// before\nhttp://host:1984/api/stream.flv?src=cameara1\n// after\nhttp://host:1984/api/stream.flv?src=camera1","handlingStrategy":"validation","validationCode":"const streams = await (await fetch('/api/streams')).json();\nif (!streams.some(s => s.name === src)) throw new Error(`stream '${src}' not configured`);","typeGuard":null,"tryCatchPattern":"const res = await fetch(`/api/stream.flv?src=${encodeURIComponent(src)}`);\nif (res.status === 404) { /* stream missing: create it or fix the name */ }\nelse if (!res.ok) throw new Error(await res.text());","preventionTips":["Keep stream names in one shared constant/config to avoid typos","List /api/streams before consuming to confirm the name exists","Remember dynamic streams disappear after restart — recreate on boot","Case-sensitive: match stream names exactly"],"tags":["http","rtmp","flv","stream"],"backgroundTag":"resource-not-found","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}