Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve reconnection handling with a state machine #39

Open
3 tasks
zehnm opened this issue Jan 2, 2024 · 0 comments
Open
3 tasks

Improve reconnection handling with a state machine #39

zehnm opened this issue Jan 2, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@zehnm
Copy link
Contributor

zehnm commented Jan 2, 2024

The current reconnection handling to the HA server is more of a quick and dirty implementation than a proper solution.
With the new reconfiguration options there's a chance of a race condition, where suddenly two client connections are active. This interferes with heartbeat timeouts and can lead to constant reconnections. This has been seen in unfoldedcircle/feature-and-bug-tracker#243

The core already uses a state machine implementation for the WebSocket integration driver connections. This could probably be used as a starting point with some modifications (e.g. no authentication_error transition from the transient Connecting state, because of no header-based authentication):

image

Tasks:

  • analyze if we just need an additional "(re)-connection state-machine" (as shown above), or an overall state-machine which includes the current setup-flow state machine
  • design state machine(s)
  • replace current flag based reconnect with state machine implementation
@zehnm zehnm added the enhancement New feature or request label Jan 2, 2024
zehnm added a commit that referenced this issue Jan 2, 2024
If the driver is reconfigured, disconnect and connect again with the new
connection settings.
Closes #36

Further improvements:
- Patch up reconnection logic to (hopefully) prevent multiple client
  connections.
- More log information to track down multiple connections.
- Use a unique connection id for each new HA client connection (counter
  suffix).

Relates to #39
Relates to unfoldedcircle/feature-and-bug-tracker#243
zehnm added a commit that referenced this issue Jan 2, 2024
If the driver is reconfigured, disconnect and connect again with the new
connection settings.
Closes #36

Further improvements:
- Patch up reconnection logic to (hopefully) prevent multiple client
  connections.
- More log information to track down multiple connections.
- Use a unique connection id for each new HA client connection (counter
  suffix).

Relates to #39
Relates to unfoldedcircle/feature-and-bug-tracker#243
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant