AlexxIT/go2rtc · error
wrong status
Error message
wrong status: ${res.Status} What it means
WebSocket Dial upgrade guard: the server's response to the upgrade request is not 101 Switching Protocols (res.Status appended). The endpoint did not accept the WebSocket handshake — often auth failure (401), wrong path (404), or a plain HTTP responder.
Solutions
- Check the appended status: 401 -> credentials needed, 404 -> wrong WebSocket path
- Confirm the URL points at a WebSocket endpoint, not plain HTTP
- Ensure required headers (Authorization, subprotocol) are provided
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at pkg/tcp/websocket/dial.go:44 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/c0fac7197cb45aed.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/tcp/websocket/dial.go:44
return nil, err
}
key, accept := GetKeyAccept()
// Version, Key, Protocol important for Axis cameras
req.Header.Set("Connection", "Upgrade")
req.Header.Set("Upgrade", "websocket")
req.Header.Set("Sec-WebSocket-Version", "13")
req.Header.Set("Sec-WebSocket-Key", key)
req.Header.Set("Sec-WebSocket-Protocol", "binary")
res, err := tcp.Do(req)
if err != nil {
return nil, err
}
if res.StatusCode != http.StatusSwitchingProtocols {
return nil, errors.New("wrong status: " + res.Status)
}
if res.Header.Get("Sec-Websocket-Accept") != accept {
return nil, errors.New("wrong websocket accept")
}
return NewClient(*pconn), nil
}
func GetKeyAccept() (key, accept string) {
b := make([]byte, 16)
_, _ = cryptorand.Read(b)
key = base64.StdEncoding.EncodeToString(b)
h := sha1.New()
h.Write([]byte(key))
h.Write([]byte("258EAFA5-E914-47DA-95CA-C5AB0DC85B11"))
accept = base64.StdEncoding.EncodeToString(h.Sum(nil))View on GitHub (pinned to c245815e75)