AlexxIT/go2rtc · error
hds: write buffer too big
Error message
hds: write buffer too big
What it means
HDS Write guard: the payload exceeds the protocol maximum of 0xFFFFFF bytes (the 3-byte length field in the frame header cannot represent it). The write is refused before any bytes hit the wire; the caller must split the data.
Solutions
- Chunk writes into blocks smaller than ~16MB
- Stream data incrementally instead of building one huge buffer
- Bound snapshot/media payloads upstream to fit HDS frame limits
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at pkg/hap/hds/hds.go:126 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/b2f1ca71f3ca5a94.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/hap/hds/hds.go:126
for {
b, err := c.read()
if err != nil {
return total, err
}
n, err := w.Write(b)
total += int64(n)
if err != nil {
return total, err
}
}
}
func (c *Conn) Write(b []byte) (n int, err error) {
n = len(b)
if n > 0xFFFFFF {
return 0, errors.New("hds: write buffer too big")
}
verify := make([]byte, 4)
binary.BigEndian.PutUint32(verify, 0x01000000|uint32(n))
if _, err = c.wr.Write(verify); err != nil {
return
}
nonce := make([]byte, hap.NonceSize)
binary.LittleEndian.PutUint64(nonce, c.encryptCnt)
c.encryptCnt++
buf := make([]byte, n+hap.Overhead)
if _, err = chacha20poly1305.EncryptAndSeal(c.encryptKey, buf[:0], nonce, b, verify); err != nil {
return
}
if _, err = c.wr.Write(buf); err != nil {View on GitHub (pinned to c245815e75)