Skip to content

fix(connection): retry failed session establishment - #761

Open
faysou wants to merge 1 commit into
wboayue:mainfrom
faysou:fix/reconnect-session-establishment
Open

fix(connection): retry failed session establishment#761
faysou wants to merge 1 commit into
wboayue:mainfrom
faysou:fix/reconnect-session-establishment

Conversation

@faysou

@faysou faysou commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Keep the sync and async reconnect loops active when the socket reopens but session establishment fails. This covers the interval where TWS accepts TCP connections before its API handshake is ready, such as during an automated restart.

stateDiagram-v2
    [*] --> ReconnectSocket
    ReconnectSocket --> EstablishSession: socket connected
    ReconnectSocket --> Backoff: socket error
    EstablishSession --> Connected: session ready
    EstablishSession --> Backoff: handshake or startup error
    Backoff --> ReconnectSocket: attempts remain
    Backoff --> Failed: attempts exhausted
Loading

A reconnect succeeds only after the complete session is ready. Transient establishment failures consume an attempt and follow the existing backoff policy.

Testing

  • cargo test -p ibapi --features sync.
  • Sync and async tests with an incompatible handshake followed by a valid handshake.
  • Paper TWS restart smoke: reconnect survived the startup window and downstream subscriptions resumed.

- Retry when TCP reconnects before the TWS session is ready
- Cover sync and async paths with transient handshake tests
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