AlexxIT/go2rtc · error

data too short: bytes

Error message

data too short: %d bytes

What it means

parseK10001 expects the HL-framed K10001 challenge payload to be at least 33 bytes (HL magic + fixed header + challenge data). If the received data is shorter, it returns "data too short: N bytes" so the caller doesn't index out of bounds.

Solutions

  1. Enable verbose logging to see the received byte count and dump the payload.
  2. Confirm camera credentials and re-pair if the camera is sending rejection frames instead of challenges.
  3. Retry the connection — a single truncated frame is often transient packet loss.
  4. If consistently short, check firmware compatibility; the challenge format may differ from the library's expectation.
Defensive patterns

Strategy: validation

Try / catch

if err := client.Dial(); err != nil {
    if strings.Contains(err.Error(), "data too short") {
        return fmt.Errorf("camera sent non-challenge K10001 frame: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Camera replied to K10000 with an empty or minimal status frame instead of a full challenge; truncated UDP/DTLS packet; firmware sending a rejection/keepalive frame where a challenge was expected.

Common situations: Camera rejecting the session early with a short error frame; network corruption dropping payload bytes; firmware version whose K10001 is smaller than the expected 33-byte layout.

Related errors


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

Appendix: source

Thrown at pkg/wyze/client.go:470

func (c *Client) buildK10056(frameSize uint8, bitrate uint16) []byte {
	b := make([]byte, 21)
	copy(b, "HL")                                           // magic
	b[2] = 5                                                // version
	binary.LittleEndian.PutUint16(b[4:], KCmdSetResolution) // 10056
	binary.LittleEndian.PutUint16(b[6:], 5)                 // payload len
	b[16] = frameSize + 1                                   // frame size
	binary.LittleEndian.PutUint16(b[17:], bitrate)          // bitrate
	// b[19:21] = FPS (0 = auto)
	return b
}

func (c *Client) parseK10001(data []byte) (challenge []byte, status byte, err error) {
	if c.verbose {
		fmt.Printf("[Wyze] parseK10001: received %d bytes\n", len(data))
	}

	if len(data) < 33 {
		return nil, 0, fmt.Errorf("data too short: %d bytes", len(data))
	}

	if data[0] != 'H' || data[1] != 'L' {
		return nil, 0, fmt.Errorf("invalid HL magic: %x %x", data[0], data[1])
	}

	cmdID := binary.LittleEndian.Uint16(data[4:])
	if cmdID != KCmdChallenge {
		return nil, 0, fmt.Errorf("expected cmdID 10001, got %d", cmdID)
	}

	status = data[16]
	challenge = make([]byte, 16)
	copy(challenge, data[17:33])

	return challenge, status, nil
}

View on GitHub (pinned to c245815e75)