Add IB Gateway auto-logoff detection#8
Merged
Conversation
When IB Gateway's auto-logoff timer fires, the TCP socket can linger without ib_async firing disconnectedEvent, leaving the daemon in a zombie-connected state with no reconnection triggered. This change adds a lightweight active health check (reqCurrentTimeAsync) to the monitor loop that detects stale sessions within seconds and forces reconnection. Changes: - IBProvider.check_health(): Pings gateway with 5s timeout, forces disconnect and reschedules reconnect on failure - IBProvider._force_disconnect(): Tears down stale connection and schedules exponential backoff reconnect - DaemonServer._monitor_loop: Calls check_health before drawdown check; on failure broadcasts disconnected event - BrokerProvider base class: Default no-op check_health() for non-IB providers - Tests: 5 new tests covering alive, timeout, exception, and edge cases Co-authored-by: Bryce Bjork <brycedbjork@gmail.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
Detects IB Gateway auto-logoff by actively polling the session every 5 seconds. When the session dies (auto-logoff timer fires or connection is lost), the daemon detects it within one monitor cycle and automatically reconnects using exponential backoff, rather than sitting indefinitely in a zombie-connected state.
Changes
reqCurrentTimeAsync()(5s timeout). Returns true if alive; on failure, forces disconnect and reschedules reconnect via existing exponential backoff.check_health()before the drawdown check. On failure, notifiesConnectionLossMonitorand broadcasts a disconnected event.check_health()for non-IB providers.All 102 existing tests pass; 5 new tests added.
🤖 Generated with Claude Code