Skip to content

fix: back off on 429s without a block duration instead of retrying after 5s - #205

Closed
Remper1997 wants to merge 1 commit into
fustom:mainfrom
Remper1997:fix/429-unparsable-backoff
Closed

Remper1997 wants to merge 1 commit into
fustom:mainfrom
Remper1997:fix/429-unparsable-backoff

Conversation

@Remper1997

@Remper1997 Remper1997 commented Nov 24, 2026 •

Copy link
Copy Markdown

Problem

The Ariston cloud often answers HTTP 429 with a bare Requests are blocked body. _parse_block_seconds() finds no duration, so the client waits a fixed 5 s and retries. _blocked_until is also set to only 5 s, so the other coordinators resume after the same 5 s. The account stays blocked indefinitely and all entities stay unavailable.

Seen on a GALEVO heat pump (HA 2026.11, default scan intervals): in ~1.5 h there were 83 Rate limited (429) without parsable block duration; falling back to 5s wait warnings and 23 ConnectionException: (429, b'Requests are blocked') tracebacks. Reported in fustom/ariston-remotethermo-home-assistant-v3#545.

Change

  • Unknown block duration: no inline retry. All requests on the instance pause for 60 s. Each further consecutive 429 doubles the pause, up to 15 min. The next successful response resets it. Concurrent requests rejected by the same block (e.g. the asyncio.gather of properties and menu items) count as one strike.
  • Retry-After header: honoured (delta-seconds) when the body has no duration.
  • Known duration (blocked for N seconds): unchanged. Sleep N+1 s, retry once.
  • New RateLimitException(ConnectionException): exported from ariston. It keeps args == (429, content), so existing error.args[0] checks still work, and adds retry_after (seconds until the block window ends). It is raised both for a 429 response and when a request is skipped inside the block window. Callers like the HA coordinators can then schedule their next poll instead of hammering the cloud.

Sync (requests) and async (aiohttp) paths share the same logic (_register_rate_limit, _raise_if_blocked).

Tests

python -m unittest discover -s tests: 102 tests OK. tests/test_rate_limit.py covers:

  • no blind retry for a bare 429, plus the exception shape;
  • the 60 → 120 → 240 → 480 → 900 → 900 back-off;
  • reset after a success;
  • Retry-After;
  • concurrent 429s counting as one strike;
  • retry_after on short-circuited requests.

The new tests fail on the previous code.

Real-world check

Installed on an affected HA 2026.11 (GALEVO) together with the companion integration PR. After the restart the log shows Rate limited (429) without a block duration (1 in a row); pausing requests for 60 seconds, and setup retries are spaced ≥60 s apart. The flood of 5 s retries and tracebacks is gone.

A companion PR in the integration turns these into paced UpdateFailed / ConfigEntryNotReady. It also works with the current library release.

🤖 Generated with Claude Code

…ter 5s

The Ariston cloud often answers HTTP 429 with a bare "Requests are blocked"
body. The client then waited a fixed 5 seconds and retried, and the other
coordinators resumed after the same 5 seconds, which kept the account
blocked indefinitely (fustom/ariston-remotethermo-home-assistant-v3#545).

- Without a known duration, do not retry inline; pause all requests on the
  instance for 60s, doubling per consecutive 429 up to 15 minutes, and reset
  after the next successful response. Concurrent requests rejected by the
  same block count as one strike.
- Honour a delta-seconds Retry-After header when the body has no duration.
- Raise RateLimitException (a ConnectionException subclass that keeps
  args == (429, content)) carrying retry_after, also when a request is
  skipped inside the block window, so callers can schedule their next poll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Remper1997
Remper1997 force-pushed the fix/429-unparsable-backoff branch from 321c13f to 99091ba Compare November 24, 2026 23:40
@Remper1997

Copy link
Copy Markdown
Author

Closing this as a duplicate of #200 and #202, which I missed before opening it. Both cover the same unparsable-429 back-off and also cut the number of GALEVO menu requests, which this PR doesn't. Sorry for the noise.

In case it helps the review, here is data from an affected setup (GALEVO heat pump, HA 2026.11.0, integration v0.20.9, default scan intervals). This was the account-wide Requests are blocked loop from fustom/ariston-remotethermo-home-assistant-v3#545:

  • Before: 83 × Rate limited (429) without parsable block duration; falling back to 5s wait and 23 × ConnectionException: (429, b'Requests are blocked') tracebacks in ~1.5 h. All entities were unavailable.
  • With a 60 s non-retrying back-off: setup retries were spaced ≥60 s apart, and there were no further 429s once HA's own setup back-off took over.

Note that the concurrency issue raised on #202 (an in-flight 429 with a short duration, or a 500 retry, bypassing an active cooldown because is_retry skips the block check) applies to this PR's code as well.

The Home Assistant side is in fustom/ariston-remotethermo-home-assistant-v3#558. It turns 429s into paced UpdateFailed / ConfigEntryNotReady and works with whichever library fix lands. It reads retry_after from the exception if present, and otherwise falls back to args[0] == 429.

@Remper1997 Remper1997 closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant