AlexxIT/go2rtc · error

wyze: K10001 failed

Error message

wyze: K10001 failed: %w

What it means

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".

Solutions

  1. Retry the whole Dial sequence — the K handshake must run in one fresh session.
  2. Confirm camera firmware is compatible with the K-auth protocol this library implements.
  3. Check the DTLS connection stayed alive (no concurrent Close on the client).
  4. Add a bounded retry with backoff around Dial for flaky networks.

Example fix

// before
client.Dial() // partially failed at K10001, ignored

// after
if err := client.Dial(); err != nil {
    if strings.Contains(err.Error(), "K10001 failed") {
        time.Sleep(1 * time.Second)
        err = client.Dial() // full reconnect retry
    }
    if err != nil {
        return err
    }
}
Defensive patterns

Strategy: retry

Try / catch

if err := client.Dial(); err != nil {
    if strings.Contains(err.Error(), "K10001 failed") {
        // session-scoped handshake: retry the whole Dial, not just this step
        time.Sleep(time.Second)
        err = client.Dial()
    }
    if err != nil {
        return err
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/51e0adc77c96e9b5. Report an issue: GitHub.

Appendix: source

Thrown at pkg/wyze/client.go:339

	if c.verbose {
		fmt.Printf("[Wyze] Sending AV Login\n")
	}

	if err := c.conn.AVClientStart(5 * time.Second); err != nil {
		return fmt.Errorf("wyze: av login failed: %w", err)
	}

	if c.verbose {
		fmt.Printf("[Wyze] AV Login response received\n")
	}
	return nil
}

func (c *Client) doKAuth() error {
	// Step 1: K10000 -> K10001 (Challenge)
	data, err := c.conn.WriteAndWaitIOCtrl(c.buildK10000(), c.matchHL(KCmdChallenge), 5*time.Second)
	if err != nil {
		return fmt.Errorf("wyze: K10001 failed: %w", err)
	}

	hlData := c.extractHL(data)
	challenge, status, err := c.parseK10001(hlData)
	if err != nil {
		return fmt.Errorf("wyze: K10001 parse failed: %w", err)
	}

	if c.verbose {
		fmt.Printf("[Wyze] K10001 challenge received, status=%d\n", status)
	}

	// Step 2: K10002 -> K10003 (Auth)
	data, err = c.conn.WriteAndWaitIOCtrl(c.buildK10002(challenge, status), c.matchHL(KCmdAuthResult), 5*time.Second)
	if err != nil {
		return fmt.Errorf("wyze: K10002 failed: %w", err)
	}
	hlData = c.extractHL(data)

View on GitHub (pinned to c245815e75)