AlexxIT/go2rtc · error
res.Status
Error message
res.Status
What it means
pkg/xiaomi cloud Request performs an HTTP call to the Xiaomi cloud API. Any non-200 status code is converted to an error whose message is the raw res.Status line (e.g. '403 Forbidden'), since Xiaomi signals failures at the HTTP level rather than in the JSON body.
Solutions
- Re-login to refresh cookies/service tokens, then retry the request
- Check the status code text in the error to identify 401/403 (auth) vs 429 (rate limit) vs 5xx (server)
- Verify the correct regional API endpoint for your Xiaomi account
- Reduce polling frequency if hitting rate limits
Example fix
// before
resp, err := cloud.Request(staleClient, url, payload) // errors: res.Status
// after
if err := cloud.Login(user, pass); err != nil { return err } // refresh tokens first
resp, err := cloud.Request(freshClient, url, payload) Defensive patterns
Strategy: retry
Try / catch
res, err := cloud.Request(client, url, payload)
if err != nil {
if strings.Contains(err.Error(), "401") || strings.Contains(err.Error(), "403") {
// re-authenticate then retry once
}
return err
} Prevention
- Refresh Xiaomi session cookies proactively before expiry
- Use the correct regional endpoint for the account
- Back off on 429/5xx instead of hammering the API
When it happens
Trigger: Calling xiaomi cloud Request when the server returns a non-OK status: expired/invalid auth cookies or service token, rate limiting, server-side 5xx, or wrong endpoint/region.
Common situations: Stale stored login cookies after Xiaomi session expiry; calling the wrong regional endpoint (cn vs de vs us); Xiaomi throttling frequent polling requests.
Related errors
AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07).
Data as JSON: /api/errors/36f870aaeb101a6e.
Report an issue: GitHub.
Appendix: source
Thrown at pkg/xiaomi/cloud.go:438
if err != nil {
return nil, err
}
req.Header.Set("Cookie", c.cookies)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
for k, v := range headers {
req.Header.Set(k, v)
}
res, err := c.client.Do(req)
if err != nil {
return nil, err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return nil, errors.New(res.Status)
}
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
ciphertext, err := base64.StdEncoding.DecodeString(string(body))
if err != nil {
return nil, err
}
plaintext, err := crypt(signedNonce, ciphertext)
if err != nil {
return nil, err
}
var res1 struct {View on GitHub (pinned to c245815e75)