{"record":{"id":"1c24cf711fc1505a","repo":"AlexxIT/go2rtc","slug":"wyze-connect-failed-w","errorCode":null,"errorMessage":"wyze: connect failed: %w","messagePattern":"wyze: connect failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/wyze/client.go","lineNumber":309,"sourceCode":"\t}\n\n\treturn nil\n}\n\nfunc (c *Client) connect() error {\n\thost := c.host\n\tport := 0\n\n\tif idx := strings.Index(host, \":\"); idx > 0 {\n\t\tif p, err := strconv.Atoi(host[idx+1:]); err == nil {\n\t\t\tport = p\n\t\t}\n\t\thost = host[:idx]\n\t}\n\n\tconn, err := dtls.DialDTLS(host, port, c.uid, c.authKey, c.enr, c.verbose)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"wyze: connect failed: %w\", err)\n\t}\n\n\tc.conn = conn\n\tif c.verbose {\n\t\tfmt.Printf(\"[Wyze] Connected to %s (IOTC + DTLS)\\n\", conn.RemoteAddr())\n\t}\n\n\treturn nil\n}\n\nfunc (c *Client) doAVLogin() error {\n\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}","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/AlexxIT/go2rtc/blob/c245815e75e2a5fd60b4290f12bfc04e55a984d3/pkg/wyze/client.go#L291-L327","documentation":"Dial establishes the IOTC session and then the DTLS tunnel to the camera via dtls.DialDTLS. Any failure in that handshake (unreachable camera, bad UID/authKey/enr credentials, DTLS negotiation failure) is wrapped as \"wyze: connect failed\".","triggerScenarios":"Camera offline or on a different network; wrong UID, authKey, or enr passed to the Client; DTLS handshake rejected by camera; firewall/NAT blocking UDP to the camera; host string contains a path/invalid address.","commonSituations":"Stale credentials after re-pairing the camera in the Wyze app; camera powered off or firmware updating; WAN vs LAN connection issues (camera only reachable via P2P relay that's down); typo in host/IP.","solutions":["Verify camera is online (LED/ping/Wyze app) and reachable from this machine/network.","Re-fetch UID/authKey/enr from the Wyze API — re-pairing invalidates old keys.","Check the host string is the bare host/IP (code strips anything after a separator before dialing).","Retry with backoff for transient P2P/relay failures; check firewall allows outbound UDP."],"exampleFix":"// before\nclient := wyze.NewClient(uid, authKey, enr)\nclient.Dial()\n\n// after\nclient := wyze.NewClient(uid, authKey, enr)\nif err := client.Dial(); err != nil {\n    return fmt.Errorf(\"check camera online & credentials: %w\", err)\n}","handlingStrategy":"retry","validationCode":"if host == \"\" || uid == \"\" || authKey == \"\" || enr == \"\" {\n    return fmt.Errorf(\"missing camera host/uid/authKey/enr\")\n}","typeGuard":null,"tryCatchPattern":"if err := client.Dial(); err != nil {\n    var nerr net.Error\n    if errors.As(err, &nerr) && nerr.Timeout() {\n        // retry with backoff\n    }\n    return fmt.Errorf(\"cannot reach camera: %w\", err)\n}","preventionTips":["Confirm camera is online before dialing (app status or ping)","Re-fetch credentials after camera re-pairing","Use bounded exponential backoff retries around Dial"],"tags":["go","dtls","iot","connection"],"backgroundTag":"connection-refused","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"}