Rate-limit hardening, reliable SSE reconnect & event-thread decoupling (builds 15–19)#18
Open
bumaas wants to merge 5 commits into
Open
Rate-limit hardening, reliable SSE reconnect & event-thread decoupling (builds 15–19)#18bumaas wants to merge 5 commits into
bumaas wants to merge 5 commits into
Conversation
Device: - Leichter Wert-Refresh (refreshDeviceValues) bei Reconnect/Neustart statt nur bei needsInitialization -> kein veralteter Status/OperationState mehr. - 30s-Throttle (refreshThrottled) fuer Init- und Refresh-Pfad gegen den Request-Sturm bei CONNECTED/IM_CHANGESTATUS-Bursts. - Transition-Guard in MessageSink: nur echte Parent-Statuswechsel loesen Refresh aus. - Profil-Guard: IPS_SetVariableProfileValues nur auf numerischen Profilen (behebt "Werte von String-Profilen koennen nicht modifiziert werden"). - Diagnose-Debug (Trigger/Modus, refreshDeviceValues done (N requests)). Cloud: - stopEventStream: IO waehrend Rate-Limit-Sperre deaktivieren -> kein 60s-/events-Hammering, das rollierende 24h-Fenster kann leerlaufen. - Ehrlicher Status 201 (STATUS_RATE_LIMITED) statt IS_ACTIVE, inkl. dt. Locale. - invalid_token-Handler: abgelaufener Token im Stream -> sofort Reconnect mit frischem Token statt 401-Dauerloop. - Tageszaehler RequestDayCount in ForwardData (Diagnose des Verbrauchs). Configurator: - Bereits angelegte Geraeteinstanzen werden immer gelistet, auch wenn die Live-Discovery scheitert (Rate-Limit/offline) - kein Frueh-Return mehr. Tests: 30 -> 34 gruen (neue Regressionstests fuer Throttle/Transition, IO-Stopp/Reset, Status 201 und invalid_token-Reconnect); Cloud-Tests registrieren die Parent-IO-Properties selbst, kein SymconStubs-Patch noetig. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
CheckServerEvents verbindet bei veraltetem Keep-Alive jetzt unabhängig vom Parent-Status neu (HasActiveParent-Tor entfernt) - ein toter Stream wird so auch bei fehlerhaftem Parent wiederhergestellt. Der Fehler-Backoff ist auf 3 Minuten gedeckelt (statt bis zu 1 Stunde); lange Wartezeiten bleiben echten Rate-Limits (429) vorbehalten. Regressionstests: Reconnect trotz inaktivem Parent, Backoff-Cap 180s (36 Tests). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Der SelectedProgram-NOTIFY loeste bisher einen synchronen Cloud-Call in
ReceiveData auf dem Flow-Handler-Thread aus - bei parallelem Stream-Reconnect
fuehrte das zu "Warten auf Skriptresultat fehlgeschlagen" (Thread-Stau). Der
Refresh laeuft jetzt entkoppelt: RegisterOnceTimer -> RequestAction
('RefreshSelectedProgram') auf eigenem Thread, ReceiveData kehrt sofort zurueck.
Ersetzt die Zwischenloesung (statischer Timer + oeffentliche Methode); getTime()
entfernt.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Der CONNECTED-Event rief in ReceiveData weiterhin synchron
refreshDeviceState -> refreshDeviceValues/InitializeDevice auf dem Flow-Thread
auf. Waehrend eines Stream-Reconnects antwortet der Parent nicht rechtzeitig ->
Flow-Thread blockiert -> "Warten auf Skriptresultat fehlgeschlagen". Der Refresh
laeuft jetzt entkoppelt: RegisterOnceTimer -> RequestAction('RefreshDeviceState')
auf eigenem Thread (analog zum SelectedProgram-Fix aus Build 17).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Jede erfolgreiche Anfrage (getData 200 / putData 204 / deleteData 204) rief bisher ResetRateLimit -> ForceRegisterServerEvents -> IPS_ApplyChanges($parent) auf und verband damit die SSE-IO bei jeder Bedienung neu (Verbindung schliesst/ oeffnet, Event-Control-Statusflackern). ResetRateLimit laeuft jetzt nur noch, wenn tatsaechlich eine Sperre anlag (neuer Helper clearRateLimitAfterSuccess, Guard auf RateLimitUntil != 0). Danke an Thomas fuer den Hinweis. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR builds on the current
master(build 14) and adds the hardening from builds 15–19. It is the delta only; the tree matches our tested fork state. All 40 PHPUnit tests pass.Motivation
Field logs showed three recurring problems: the daily rate limit becoming self-perpetuating, the event stream not recovering after an idle/abort, and
FlowHandler/"Warten auf Skriptresultat fehlgeschlagen" thread pile-ups during bursts/reconnects.Changes
Cloud (
Home Connect Cloud)/eventsevery ~60 s. With a rolling 24 h quota those retries kept the window full and the block never ended. The IO is re-registered (fresh token) when the block clears.IS_ACTIVEwhile blocked.invalid_tokenon the stream: refresh the token and re-register instead of looping on 401.CheckServerEventsreconnects on a stale keep-alive regardless of the parent status (the oldHasActiveParent()gate prevented recovery of a dead parent); reconnect backoff capped at 3 min (long backoff reserved for real rate limits).ResetRateLimit()(→IPS_ApplyChangeson the IO) now only runs when a block was actually pending, so normal operations no longer close/reopen the stream.Device (
Home Connect Device)OperationStateblocking program selection), without the expensive structure re-init.SelectedProgramandCONNECTEDno longer perform synchronous cloud requests insideReceiveData(root cause of the thread pile-ups). They defer viaRegisterOnceTimer→RequestAction.Configurator
Tests
PHPUnit suite extended from 30 → 40 tests (regressions for rate-limit stop/status, invalid_token, reconnect + backoff cap, no-reconnect-on-success, throttle/transition guard, value refresh, deferred SelectedProgram/CONNECTED refresh). All green.