{"record":{"id":"2fbc934a31d67304","repo":"AlexxIT/go2rtc","slug":"err-error-2fbc93","errorCode":null,"errorMessage":"err.Error()","messagePattern":"err\\.Error\\(\\)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/rtmp/rtmp.go","lineNumber":188,"sourceCode":"\th := w.Header()\n\th.Set(\"Content-Type\", \"video/x-flv\")\n\n\t_, _ = cons.WriteTo(w)\n\n\tstream.RemoveConsumer(cons)\n}\n\nfunc inputFLV(w http.ResponseWriter, r *http.Request) {\n\tdst := r.URL.Query().Get(\"dst\")\n\tstream := streams.Get(dst)\n\tif stream == nil {\n\t\thttp.Error(w, api.StreamNotFound, http.StatusNotFound)\n\t\treturn\n\t}\n\n\tclient, err := flv.Open(r.Body)\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tstream.AddProducer(client)\n\n\tif err = client.Start(); err != nil && err != io.EOF {\n\t\tlog.Warn().Err(err).Caller().Send()\n\t}\n\n\tstream.RemoveProducer(client)\n}\n","sourceCodeStart":170,"sourceCodeEnd":200,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/internal/rtmp/rtmp.go#L170-L200","documentation":"After the destination stream is found, inputFLV calls flv.Open(r.Body) to parse the incoming FLV data; any parse/IO error is echoed verbatim with HTTP 500. This means the request body was not a valid, readable FLV stream (bad header, truncated data, or empty body).","triggerScenarios":"POSTing a body to the FLV input endpoint whose bytes are not FLV (wrong container, gzip, empty body, connection closed mid-stream), so flv.Open fails while reading the FLV header/tags.","commonSituations":"A script pipes MP4/RTSP data instead of FLV; the sending client aborted early; a proxy stripped the body; wrong Content-Type assumption in custom integrations.","solutions":["Ensure the client actually sends a valid FLV byte stream (starts with 'FLV' signature)","Check the sender isn't closing the connection before the header/tags are written","Verify no proxy/CDN is altering or truncating the body","Inspect the returned error text — it names the exact parse/read failure"],"exampleFix":"// before\ncurl -X POST --data-binary file.mp4 'http://host/api/stream.flv?dst=cam'\n// after\nffmpeg -i input -c copy -f flv - | curl -X POST --data-binary @- 'http://host/api/stream.flv?dst=cam'","handlingStrategy":"validation","validationCode":"// verify the payload is FLV before sending\nconst head = new Uint8Array(await file.slice(0, 3).arrayBuffer());\nif (String.fromCharCode(...head) !== 'FLV') throw new Error('not an FLV stream');","typeGuard":"function isFLV(buf) { return buf.length >= 9 && buf[0]===0x46 && buf[1]===0x4C && buf[2]===0x56; }","tryCatchPattern":"const res = await fetch(url, {method:'POST', body: flvBody});\nif (!res.ok) { const msg = await res.text(); throw new Error(`flv.Open failed: ${msg}`); }","preventionTips":["Use ffmpeg -f flv (or an FLV muxer) to generate the body — never raw MP4/RTSP","Keep the connection open until the stream ends; avoid early aborts","Test through any proxy to confirm the body arrives unmodified","Check the response text: it names the exact header/tag parse failure"],"tags":["http","flv","parse","streaming"],"backgroundTag":"invalid-argument-format","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"}