AlexxIT/go2rtc · error
hap: wrong response: %#v, on request: %#v
Error message
hap: wrong response: %#v, on request: %#v
What it means
newResponseError reports that a HAP control response did not match what was expected for the given request. Dial, Pair and DeletePairing use it when decoding a response whose structure or result fields are invalid. Both the response and the original request are dumped with %#v for diagnosis.
Solutions
- Inspect the dumped request/response to see which field the device returned instead of the expected one.
- Confirm the accessory supports HAP pairing and is on the expected firmware/version.
- Delete stale pairings on the accessory and re-pair from scratch.
- Ensure the connection targets the accessory's HAP port (default 51826/TCP or advertised port), not another service.
Example fix
// before
conn, err := hap.Dial(accessoryAddr) // points at camera RTSP port 8554
// after
conn, err := hap.Dial("192.168.1.42:51826") // actual HAP port Defensive patterns
Strategy: retry
Validate before calling
// verify host:port is the accessory HAP port before dialing
conn, err := net.DialTimeout("tcp", addr, 3*time.Second) Try / catch
conn, err := hap.Dial(addr)
if err != nil {
if strings.Contains(err.Error(), "wrong response") {
// unpublish + re-pair
}
return err
} Prevention
- Re-pair from scratch after firmware updates on the accessory
- Confirm the device actually implements HAP on the dialed port
- Avoid TLS-intercepting proxies between client and accessory
- Pin the library version known to work with your accessory firmware
When it happens
Trigger: Calling hap Dial/Pair/DeletePairing against an accessory whose reply body fails to decode into the expected response type, or whose TLV indicates an error/unsupported state.
Common situations: Targeting a non-HAP or wrong-version device (e.g. HAP 1.x quirks); the accessory rejected the pairing method and returned an error TLV; network proxy rewriting the response body.
Understand the failure class
Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.
Related errors
- hap: wrong request: %#v
- hap: no free streams
- hap: GetAccessories zero answer
- hap: wrong http status:
- hap: PairVerify with unknown client_id:
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/018e6564a5fd2ece.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/hap/helpers.go:129
for _, item := range items {
switch v := item.(type) {
case string:
b = append(b, v...)
case []byte:
b = append(b, v[:]...)
default:
panic(v)
}
}
return
}
func newRequestError(req any) error {
return fmt.Errorf("hap: wrong request: %#v", req)
}
func newResponseError(req, res any) error {
return fmt.Errorf("hap: wrong response: %#v, on request: %#v", res, req)
}
View on GitHub (pinned to c245815e75)