{"record":{"id":"f39e8e7101befaef","repo":"AlexxIT/go2rtc","slug":"wrong-response","errorCode":null,"errorMessage":"wrong response: ","messagePattern":"wrong response: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/bubble/client.go","lineNumber":90,"sourceCode":"\t}\n\n\tif err = c.conn.SetDeadline(time.Now().Add(Timeout)); err != nil {\n\t\treturn\n\t}\n\n\treq := &tcp.Request{Method: \"GET\", URL: &url.URL{Path: u.Path, RawQuery: u.RawQuery}, Proto: \"HTTP/1.1\"}\n\tif err = req.Write(c.conn); err != nil {\n\t\treturn\n\t}\n\n\tc.r = bufio.NewReader(c.conn)\n\tres, err := tcp.ReadResponse(c.r)\n\tif err != nil {\n\t\treturn\n\t}\n\n\tif res.StatusCode != http.StatusOK {\n\t\treturn errors.New(\"wrong response: \" + res.Status)\n\t}\n\n\t// 1. Read 1024 bytes with XML, some cameras returns exact 1024, but some - 923\n\txml := make([]byte, 1024)\n\tif _, err = c.r.Read(xml); err != nil {\n\t\treturn\n\t}\n\n\t// 2. Write size uint32 + unknown 4b + user 20b + pass 20b\n\tb := make([]byte, 48)\n\tbinary.BigEndian.PutUint32(b, 44)\n\n\tif u.User != nil {\n\t\tcopy(b[8:], u.User.Username())\n\t\tpass, _ := u.User.Password()\n\t\tcopy(b[28:], pass)\n\t} else {\n\t\tcopy(b[8:], \"admin\")","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/bubble/client.go#L72-L108","documentation":"Dial (pkg/bubble/client.go:90) is establishing a session with a Bubble camera over its HTTP/TCP control channel. After sending the initial request it reads an HTTP-style response via tcp.ReadResponse; if the status code is not 200 OK it aborts and returns \"wrong response: <status>\". The appended res.Status text is the raw status line (e.g. \"401 Unauthorized\"), so this error means the camera rejected or failed the initial handshake request rather than returning a protocol error.","triggerScenarios":"Calling Dial, Unpair, TestTimeout, or TestMissedControl when the camera responds to the initial control request with a non-200 HTTP status (401 Unauthorized for bad credentials, 404/500 for wrong URL path or firmware behavior, 4xx/5xx of any kind).","commonSituations":"Wrong username/password configured for the camera; camera model or firmware that doesn't support the endpoint being hit; camera already paired to another NVR returning 403/409; pointing the client at a non-Bubble HTTP service that answers with a non-200 status; proxy or captive portal intercepting the connection.","solutions":["Read the status text embedded in the error message and fix the underlying cause: 401/403 means fix credentials or pairing state.","Verify the camera URL/path configuration matches what this driver expects for your camera model/firmware.","If the camera is paired elsewhere, use Unpair or unpair via the camera web UI before dialing.","Check camera firmware; update to a version that supports the control endpoint, or use the correct vendor driver.","Confirm you are connecting directly to the camera (no proxy/NAT rewriting the HTTP response)."],"exampleFix":"// before: credentials not set / wrong\nclient, err := bubble.Dial(ctx, logger, \"192.168.1.64:80\", \"\", \"\")\n// after: supply correct camera credentials\nclient, err := bubble.Dial(ctx, logger, \"192.168.1.64:80\", \"admin\", \"camera-password\")","handlingStrategy":"try-catch","validationCode":"// preflight the camera's HTTP endpoint\nresp, err := http.Get(\"http://\" + addr + \"/\")\nif err == nil && resp.StatusCode != http.StatusOK {\n    log.Printf(\"camera answers %s; check credentials/pairing\", resp.Status)\n}","typeGuard":null,"tryCatchPattern":"client, err := bubble.Dial(ctx, log, addr, user, pass)\nif err != nil && strings.Contains(err.Error(), \"wrong response:\") {\n    return fmt.Errorf(\"camera rejected handshake (%w); check credentials and pairing\", err)\n}","preventionTips":["Store and verify camera credentials before dialing","Unpair the camera from any previous NVR first","Pin supported camera models/firmware for this driver","Avoid proxies on the camera network path"],"tags":["network","http","camera","handshake"],"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-15T23:17:13.987Z"}