AlexxIT/go2rtc · error

dvrip: unknown packet type

Error message

dvrip: unknown packet type: %X

What it means

The DVRIP packet header's type byte (buf[3]) is not one of the recognized types (0xFC, 0xFE, 0xFD PFrame, 0xFA, 0xF9), so payload size cannot be computed. Indicates a protocol mismatch or corrupt stream; raised by ReadPacket, called from Start and probe.

Solutions

  1. Update the parser to support the new packet type emitted by this camera firmware
  2. Reconnect to resynchronize in case of stream corruption
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/dvrip/client.go:201 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/c8fca9c1c364b65b. Report an issue: GitHub.

Appendix: source

Thrown at pkg/dvrip/client.go:201

		}
		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
		}
		c.buf = append(c.buf, b...)
	}

	payload = c.buf[:size]
	c.buf = c.buf[size:]

	return
}

type Response map[string]any

func (c *Client) ReadJSON() (res Response, err error) {

View on GitHub (pinned to c245815e75)