AlexxIT/go2rtc · error

session request failed with status

Error message

session request failed with status %d: %s

What it means

Returned when the Ring session endpoint (POST ClientAPI("session")) responds with an HTTP status outside 200-299. The response body is included in the message to help diagnose why Ring rejected the session request (bad token, hardware id issues, server problems).

Solutions

  1. Read the status code and body embedded in the error message for the server's reason
  2. 401/403: force a re-authentication to get a fresh token before retrying
  3. 429: back off and reduce polling frequency
  4. Check Ring's API status / update the library if Ring changed the session API

Example fix

// before
for { dings, _ := client.ActiveDings(); time.Sleep(time.Second) } // hammers API
// after
if strings.Contains(err.Error(), "status 429") { time.Sleep(30 * time.Second) }
Defensive patterns

Strategy: retry

Validate before calling

if resp.StatusCode >= 400 { /* do not proceed; inspect resp.Body */ }

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "session request failed with status 4") {
        // re-authenticate; do not blind-retry 4xx
    } else if strings.Contains(err.Error(), "status 5") || strings.Contains(err.Error(), "status 429") {
        // exponential backoff retry
    }
}

Prevention

When it happens

Trigger: Session creation request rejected by Ring: invalid/expired auth token, invalid hardware_id header, Ring API outage or rate limiting, blocked user agent.

Common situations: Stale auth token that passed ensureAuth but Ring rejected; Ring API changed endpoints/requirements; VPN or datacenter IP blocked by Ring; 429 rate limiting from aggressive polling.

Related errors


AI-assisted analysis of AlexxIT/go2rtc@c245815e75 (2026-09-07). Data as JSON: /api/errors/804ef850e2131efd. Report an issue: GitHub.

Appendix: source

Thrown at pkg/ring/api.go:561

	if err != nil {
		return err
	}

	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("Accept", "application/json")
	req.Header.Set("Authorization", "Bearer "+c.authToken.AccessToken)
	req.Header.Set("hardware_id", c.hardwareID)
	req.Header.Set("User-Agent", "android:com.ringapp")

	resp, err := c.httpClient.Do(req)
	if err != nil {
		return err
	}
	defer resp.Body.Close()

	if resp.StatusCode < 200 || resp.StatusCode >= 300 {
		respBody, _ := io.ReadAll(resp.Body)
		return fmt.Errorf("session request failed with status %d: %s", resp.StatusCode, string(respBody))
	}

	var sessionResp SessionResponse
	if err := json.NewDecoder(resp.Body).Decode(&sessionResp); err != nil {
		return fmt.Errorf("failed to decode session response: %w", err)
	}

	c.session = &sessionResp
	c.sessionExpiry = time.Now().Add(sessionValidTime)

	// Aktualisiere den gecachten Client
	cacheMutex.Lock()
	clientCache[c.cacheKey] = c
	cacheMutex.Unlock()

	return nil
}

View on GitHub (pinned to c245815e75)