{"record":{"id":"430eb2b936655a74","repo":"AlexxIT/go2rtc","slug":"res-status-430eb2","errorCode":null,"errorMessage":"res.Status","messagePattern":"res\\.Status","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/isapi/client.go","lineNumber":58,"sourceCode":"\t}\n\treturn client, err\n}\n\nfunc (c *Client) Dial() (err error) {\n\tlink := c.url + \"/ISAPI/System/TwoWayAudio/channels\"\n\treq, err := http.NewRequest(\"GET\", link, nil)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tres, err := tcp.Do(req)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif res.StatusCode != http.StatusOK {\n\t\ttcp.Close(res)\n\t\treturn errors.New(res.Status)\n\t}\n\n\tb, err := io.ReadAll(res.Body)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\txml := string(b)\n\n\tcodec := core.Between(xml, `<audioCompressionType>`, `<`)\n\tswitch codec {\n\tcase \"G.711ulaw\":\n\t\tcodec = core.CodecPCMU\n\tcase \"G.711alaw\":\n\t\tcodec = core.CodecPCMA\n\tdefault:\n\t\treturn nil\n\t}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/isapi/client.go#L40-L76","documentation":"Dial in the ISAPI client returns a plain error built from the HTTP response status line whenever the camera/device responds with a status code other than 200 OK. It is the library's way of surfacing any non-OK HTTP response (auth failure, 404, 500, etc.) from the device during connection setup. Because it embeds only res.Status, the text is the raw status line, e.g. '401 Unauthorized'.","triggerScenarios":"Calling pkg/isapi client Dial when the HTTP response from the ISAPI endpoint has StatusCode != http.StatusOK — e.g. wrong credentials (401), wrong URL path (404), or device rejecting the request (500).","commonSituations":"Incorrect camera username/password in config; pointing at a non-ISAPI port or path; device firmware returning 403/404 for a given API; proxy or load balancer answering instead of the camera.","solutions":["Check the status text in the error message and fix the corresponding cause (401/403 => credentials/permissions, 404 => wrong path, 5xx => device-side issue).","Verify the ISAPI URL, port and path configured for the client are correct for the device model.","Confirm username/password and that the account has permission to access ISAPI endpoints.","Inspect the device's web interface / ISAPI documentation for the endpoint and retry."],"exampleFix":"// before\ncli := isapi.NewClient(isapi.WithURL(\"http://cam:80/ISAPI/Streaming/...\").WithAuth(\"admin\", \"wrongpass\"))\nconn, err := cli.Dial()\n// after\n// use correct credentials and endpoint; handle the error by inspecting the status\nconn, err := cli.Dial()\nif err != nil {\n\tif strings.Contains(err.Error(), \"401\") { /* fix credentials */ }\n\treturn err\n}","handlingStrategy":"try-catch","validationCode":"// Go: nothing to check beforehand, but verify endpoint reachability\nresp, err := http.Get(cameraURL)\nif err == nil && resp.StatusCode != http.StatusOK {\n\treturn fmt.Errorf(\"camera returned %s\", resp.Status)\n}","typeGuard":null,"tryCatchPattern":"conn, err := cli.Dial()\nif err != nil {\n\tif strings.Contains(err.Error(), \"401\") || strings.Contains(err.Error(), \"403\") {\n\t\t// re-check credentials then retry once\n\t}\n\treturn fmt.Errorf(\"isapi dial failed: %w\", err)\n}","preventionTips":["Validate camera credentials and ISAPI URL before connecting","Test the endpoint with curl/Postman to see the raw status","Keep device firmware and endpoints documented per model","Wrap Dial errors with %w so status text is preserved"],"tags":["http","network","isapi","non-200-response"],"backgroundTag":"http-error-response","analyzedSha":"c245815e75e2a5fd60b4290f12bfc04e55a984d3","analyzedAt":"2026-09-07T11:47:02.965Z","contentChangedAt":"2026-09-07T11:47:02.965Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}