AlexxIT/go2rtc · error
miss: packet header too small
Error message
miss: packet header too small
What it means
ReadPacket expects every media packet header to be at least 32 bytes (hdrSize). A shorter header means the stream is corrupted, misaligned, or coming from an unexpected firmware/protocol version, so the packet is rejected rather than parsed.
Solutions
- Drop the bad packet and resynchronize the stream (reconnect or skip)
- Update the library and camera firmware to matching versions
- Check the transport layer for partial-read bugs that could split frames
- Log the short header length to diagnose whether it is a systematic protocol mismatch
Example fix
// before
for { pkt, err := client.ReadPacket(); if err != nil { return err } } // aborts on one bad packet
// after
for {
pkt, err := client.ReadPacket()
if err != nil {
if strings.Contains(err.Error(), "header too small") { continue } // skip corrupt packet
return err
}
} Defensive patterns
Strategy: try-catch
Try / catch
pkt, err := client.ReadPacket()
if err != nil {
if strings.Contains(err.Error(), "header too small") {
// skip/resync: reconnect or continue
continue
}
return err
} Prevention
- Reconnect after any transport error to resynchronize the stream
- Keep library and camera firmware versions compatible
- Log header sizes to detect systematic protocol mismatches
When it happens
Trigger: Calling ReadPacket when the transport returns a header shorter than 32 bytes — stream desynchronization after a partial read, protocol mismatch, or truncation bug in the transport layer.
Common situations: Connecting to a camera whose firmware emits a different packet layout; corrupted stream after a network hiccup; library/firmware version mismatch.
Related errors
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/13be8c45e5fc4d1c.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/xiaomi/miss/client.go:231
switch c.model {
case ModelDafang, ModelXiaofang, "isa.camera.hlc6":
return codecPCM
case "chuangmi.camera.72ac1":
return codecOPUS
}
return 0
}
const hdrSize = 32
func (c *Client) ReadPacket() (*Packet, error) {
hdr, payload, err := c.Conn.ReadPacket()
if err != nil {
return nil, fmt.Errorf("miss: read media: %w", err)
}
if len(hdr) < hdrSize {
return nil, fmt.Errorf("miss: packet header too small")
}
payload, err = crypto.Decode(payload, c.key)
if err != nil {
return nil, err
}
pkt := &Packet{
CodecID: binary.LittleEndian.Uint32(hdr[4:]),
Sequence: binary.LittleEndian.Uint32(hdr[8:]),
Flags: binary.LittleEndian.Uint32(hdr[12:]),
Payload: payload,
}
switch c.model {
case ModelDafang, ModelXiaofang, ModelLoockV2:
// Dafang has ts in sec
// LoockV2 has ts in msec for video, but zero ts for audioView on GitHub (pinned to c245815e75)