Skip to content

Adjust auto-reconnect logic#1385

Merged
jpdillingham merged 21 commits into
masterfrom
dns
Jul 12, 2025
Merged

Adjust auto-reconnect logic#1385
jpdillingham merged 21 commits into
masterfrom
dns

Conversation

@jpdillingham

@jpdillingham jpdillingham commented Jul 5, 2025

Copy link
Copy Markdown
Member

A user on Discord questioned whether a DNS resolution failure might be breaking reconnect logic, so I went down a rabbit hole and made some changes.

Functional change:

  • Changing options while the app is trying to reconnect will attempt reconnect immediately and reset the backoff logic (users no longer have to wait ~5 minutes for the next attempt for changes to server address or port take effect)
  • Clicking the network icon on the UI also resets the backoff logic, and when connecting the app using the UI, the connection 'watchdog' is now used, ensuring retries if the initial attempt fails
  • Disconnecting via the API now cancels any in-progress reconnect process
  • The network icon overlay changes to indicate when a retry attempt is underway (green sync icon), when we're waiting for the next attempt (yellow clock) and when the app is both disconnected and not making an attempt to reconnect (red x)

Connecting:

image

Waiting:

image

Code changes:

  • Remove IConnectionWatchdog interface. Lately I'm finding C# interfaces annoying and redundant 🤷
  • Add a cancellation token to the retry logic and the delays and connection logic within to ensure the loop is exited promptly
  • Added ServerConnectionWatchdog to application state that includes flags to indicate when it's active, when it's in a retry loop, and the approximate timestamp of the next attempt

Also fixes what I'd consider a bug with the server state; address and IP are now null when the server is disconnected.

@jpdillingham jpdillingham marked this pull request as ready for review July 12, 2025 16:24
@jpdillingham jpdillingham merged commit 367b2ce into master Jul 12, 2025
4 checks passed
@jpdillingham jpdillingham deleted the dns branch July 12, 2025 19:58
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