{"record":{"id":"696f38eff8375df4","repo":"AlexxIT/go2rtc","slug":"wrong-status","errorCode":null,"errorMessage":"wrong status: ","messagePattern":"wrong status: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/image/producer.go","lineNumber":69,"sourceCode":"\n\tpkt := &rtp.Packet{\n\t\tHeader:  rtp.Header{Timestamp: core.Now90000()},\n\t\tPayload: body,\n\t}\n\tc.Receivers[0].WriteRTP(pkt)\n\n\tc.Recv += len(body)\n\n\treq := c.res.Request\n\n\tfor !c.closed {\n\t\tres, err := tcp.Do(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif res.StatusCode != http.StatusOK {\n\t\t\treturn errors.New(\"wrong status: \" + res.Status)\n\t\t}\n\n\t\tbody, err = io.ReadAll(res.Body)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tc.Recv += len(body)\n\n\t\tpkt = &rtp.Packet{\n\t\t\tHeader:  rtp.Header{Timestamp: core.Now90000()},\n\t\t\tPayload: body,\n\t\t}\n\t\tc.Receivers[0].WriteRTP(pkt)\n\t}\n\n\treturn nil\n}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/image/producer.go#L51-L87","documentation":"The image producer fetches a frame over TCP/HTTP and requires HTTP 200 OK. If the camera/source returns any other status code, Start (or the frame loop) aborts with 'wrong status: <status line>', embedding the server's response status text.","triggerScenarios":"The HTTP request issued to the camera/MJPEG source returns a non-200 status — e.g. 401/403 for wrong credentials, 404 for a wrong stream URL path, 503 when the camera is rebooting or out of sessions, or 302 if the source redirects to HTTPS.","commonSituations":"Camera URL changed or wrong path; missing/basic-auth credentials in the request; too many concurrent RTSP-over-HTTP clients; camera firmware updating; HTTP source that actually requires HTTPS so it responds with a redirect or error.","solutions":["Check the status text in the error (e.g. '401 Unauthorized') and fix the corresponding cause: credentials, URL path, or camera state","Verify the camera stream URL/path is correct by opening it in a browser or curl -i","Add authentication to the outgoing request if the source requires it","Handle redirects/HTTPS: if the camera serves TLS, use the https URL/scheme the library expects","Retry with backoff if the status is transient (503 during camera reboot)"],"exampleFix":"// before\nreq, _ := http.NewRequest(\"GET\", \"http://camera/stream\", nil)\n// after (add auth for 401)\nreq, _ := http.NewRequest(\"GET\", \"http://camera/stream\", nil)\nreq.SetBasicAuth(user, pass)","handlingStrategy":"retry","validationCode":"// preflight the source before wiring the producer\nresp, err := http.Get(cameraURL)\nif err != nil { return err }\nif resp.StatusCode != http.StatusOK {\n    return fmt.Errorf(\"camera source not ready: %s\", resp.Status)\n}\nresp.Body.Close()","typeGuard":null,"tryCatchPattern":"err := producer.Start()\nif err != nil {\n    var retriable = strings.Contains(err.Error(), \"wrong status: 50\") ||\n        strings.Contains(err.Error(), \"wrong status: 429\")\n    if retriable {\n        time.Sleep(2 * time.Second)\n        err = producer.Start()\n    }\n    return err\n}","preventionTips":["Verify camera URL and credentials with curl -i before configuring","Expect 401/404/503 and map them to auth/path/camera-state fixes","Prefer HTTPS-capable sources to avoid redirect statuses","Add retry-with-backoff around producer start for transient camera states"],"tags":["http","camera","streaming","non-200-response"],"backgroundTag":"http-non-200-response","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"}