AlexxIT/go2rtc · error

dvrip: wrong packet: %0.16x

Error message

dvrip: wrong packet: %0.16x

What it means

ReadPacket reassembled 16 bytes from chunk reads but the buffer does not start with the expected 00 00 01 DVRIP packet prefix, so the stream is not a valid DVRIP packet. The first 16 bytes are hex-dumped in the message; raised by ReadPacket, called from Start and probe.

Solutions

  1. Reconnect to the camera to resynchronize the session
  2. Verify the camera actually speaks the DVRIP protocol on this port
  3. Check credentials/login state, since error responses can corrupt framing
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/dvrip/client.go:188 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at pkg/dvrip/client.go:188

	}

	return
}

func (c *Client) ReadPacket() (pType byte, payload []byte, err error) {
	var b []byte

	// many cameras may split packet to multiple chunks
	// some rare cameras may put multiple packets to single chunk
	for len(c.buf) < 16 {
		if b, err = c.ReadChunk(); err != nil {
			return 0, nil, err
		}
		c.buf = append(c.buf, b...)
	}

	if !bytes.HasPrefix(c.buf, []byte{0, 0, 1}) {
		return 0, nil, fmt.Errorf("dvrip: wrong packet: %0.16x", c.buf)
	}

	var size int

	switch pType = c.buf[3]; pType {
	case 0xFC, 0xFE:
		size = int(binary.LittleEndian.Uint32(c.buf[12:])) + 16
	case 0xFD: // PFrame
		size = int(binary.LittleEndian.Uint32(c.buf[4:])) + 8
	case 0xFA, 0xF9:
		size = int(binary.LittleEndian.Uint16(c.buf[6:])) + 8
	default:
		return 0, nil, fmt.Errorf("dvrip: unknown packet type: %X", pType)
	}

	for len(c.buf) < size {
		if b, err = c.ReadChunk(); err != nil {
			return 0, nil, err

View on GitHub (pinned to c245815e75)