{"record":{"id":"51e0adc77c96e9b5","repo":"AlexxIT/go2rtc","slug":"wyze-k10001-failed-w","errorCode":null,"errorMessage":"wyze: K10001 failed: %w","messagePattern":"wyze: K10001 failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wyze/client.go","lineNumber":339,"sourceCode":"\tif c.verbose {\n\t\tfmt.Printf(\"[Wyze] Sending AV Login\\n\")\n\t}\n\n\tif err := c.conn.AVClientStart(5 * time.Second); err != nil {\n\t\treturn fmt.Errorf(\"wyze: av login failed: %w\", err)\n\t}\n\n\tif c.verbose {\n\t\tfmt.Printf(\"[Wyze] AV Login response received\\n\")\n\t}\n\treturn nil\n}\n\nfunc (c *Client) doKAuth() error {\n\t// Step 1: K10000 -> K10001 (Challenge)\n\tdata, err := c.conn.WriteAndWaitIOCtrl(c.buildK10000(), c.matchHL(KCmdChallenge), 5*time.Second)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"wyze: K10001 failed: %w\", err)\n\t}\n\n\thlData := c.extractHL(data)\n\tchallenge, status, err := c.parseK10001(hlData)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"wyze: K10001 parse failed: %w\", err)\n\t}\n\n\tif c.verbose {\n\t\tfmt.Printf(\"[Wyze] K10001 challenge received, status=%d\\n\", status)\n\t}\n\n\t// Step 2: K10002 -> K10003 (Auth)\n\tdata, err = c.conn.WriteAndWaitIOCtrl(c.buildK10002(challenge, status), c.matchHL(KCmdAuthResult), 5*time.Second)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"wyze: K10002 failed: %w\", err)\n\t}\n\thlData = c.extractHL(data)","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/wyze/client.go#L321-L357","documentation":"doKAuth performs the K-series application-layer authentication: it sends K10000 and waits for the K10001 challenge via WriteAndWaitIOCtrl (5s). If the IO control exchange fails (write error or timeout), the error is wrapped as \"wyze: K10001 failed\".","triggerScenarios":"Camera never sends the K10001 challenge within 5s; socket write fails because the DTLS session dropped; IO control response arrives with an unexpected command ID so the match times out.","commonSituations":"Camera dropped the session between DTLS connect and K-auth; heavily loaded camera slow to answer; protocol mismatch after firmware update changing the control reply command.","solutions":["Retry the whole Dial sequence — the K handshake must run in one fresh session.","Confirm camera firmware is compatible with the K-auth protocol this library implements.","Check the DTLS connection stayed alive (no concurrent Close on the client).","Add a bounded retry with backoff around Dial for flaky networks."],"exampleFix":"// before\nclient.Dial() // partially failed at K10001, ignored\n\n// after\nif err := client.Dial(); err != nil {\n    if strings.Contains(err.Error(), \"K10001 failed\") {\n        time.Sleep(1 * time.Second)\n        err = client.Dial() // full reconnect retry\n    }\n    if err != nil {\n        return err\n    }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := client.Dial(); err != nil {\n    if strings.Contains(err.Error(), \"K10001 failed\") {\n        // session-scoped handshake: retry the whole Dial, not just this step\n        time.Sleep(time.Second)\n        err = client.Dial()\n    }\n    if err != nil {\n        return err\n    }\n}","preventionTips":["Retry the full Dial — K-auth cannot be restarted mid-session","Avoid concurrent access to the client during handshake","Monitor packet loss to the camera"],"tags":["go","iot","authentication","timeout"],"backgroundTag":"request-timeout","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"}