Skip to content

feat(client): make the reconnect attempt limit configurable - #763

Merged
wboayue merged 3 commits into
wboayue:mainfrom
tradatious:max-reconnect-attempts
Aug 28, 2026
Merged

feat(client): make the reconnect attempt limit configurable#763
wboayue merged 3 commits into
wboayue:mainfrom
tradatious:max-reconnect-attempts

Conversation

@tradatious

Copy link
Copy Markdown
Contributor

Prior to this change, Connection::reconnect would give up after a hard-coded MAX_RECONNECT_ATTEMPTS (20 attempts, ~443 s with the capped fibonacci backoff) and then shuts the message bus down permanently. As a result, TWS/IB Gateway outages longer than ~7 minutes would kill a client apps connection, with no way to opt into a longer retry. That could be quite annoying if the client app should span the TWS/IB Gateways daily restarts and the user didn't manage to log back in in time.

This commit adds ClientBuilder::max_reconnect_attempts and ClientBuilder::reconnect_forever (async and sync) to give client apps more control. The default behaviour is unchanged.

Fixes #762

tradatious and others added 2 commits August 22, 2026 04:06
Prior to this change, Connection::reconnect would give up after a hard-coded
MAX_RECONNECT_ATTEMPTS (20 attempts, ~443 s with the capped fibonacci backoff)
and then shuts the message bus down permanently. As a result, TWS/IB Gateway
outages longer than ~7 minutes would kill a client apps connection, with no
way to opt into a longer retry. That could be quite annoying if the client app
should span the TWS/IB Gateways daily restarts and the user didn't manage to
log back in in time.

This commit adds ClientBuilder::max_reconnect_attempts and
ClientBuilder::reconnect_forever (async and sync) to give client apps more
control. The default behaviour is unchanged.
- reconnect_forever() stores None; the 20-attempt default moves into
  BuilderState::default() instead of a validate()-time unwrap_or
- Option<u32> threaded through ValidatedPieces and both connections;
  reconnect loops use is_none_or and log without a denominator when unlimited
- rename sync Connection.max_retries -> max_reconnect_attempts (async parity)
- builder docs state the default inline + examples; tests for default/override/forever
- CHANGELOG entry; README + architecture.md note the limit is configurable
@wboayue

wboayue commented Aug 28, 2026

Copy link
Copy Markdown
Owner

Pushed a follow-up commit on your branch: unlimited is now represented as Option<u32> = None internally instead of u32::MAX (the 20-attempt default moved into BuilderState::default()). Public API unchanged apart from doc wording. Also added builder tests, a CHANGELOG entry, and touched up README/architecture mentions of the fixed 20-attempt limit. Thanks for the contribution!

@wboayue
wboayue merged commit 01e2ffb into wboayue:main Aug 28, 2026
4 checks passed
@tradatious

Copy link
Copy Markdown
Contributor Author

That's awesome, thank you for taking the time to detail your changes!

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.

Consider allowing MAX_RECONNECT_ATTEMPTS to be overridden

2 participants