Skip to content

Fix reconnect loop leaving orphaned Ember+ clients - #132

Open
fredrikhareide wants to merge 1 commit into
bitfocus:masterfrom
fredrikhareide:fix/reconnect-backoff-orphaned-clients
Open

fredrikhareide wants to merge 1 commit into
bitfocus:masterfrom
fredrikhareide:fix/reconnect-backoff-orphaned-clients

Conversation

@fredrikhareide

Copy link
Copy Markdown
Contributor

If the device is unreachable, or the host/port is changed while the module is still trying to connect, the old client never stops retrying. discard() doesn't stop emberplus-connection's own 5s reconnect when the socket never connected, so you end up with more and more clients hitting the old address in the background.

  • Turn off the library's auto-reconnect and make sure a discarded client can't connect again
  • Do the reconnect in the module instead, backing off 5s, 10s, 20s, 40s, then every 60s. Resets once connected
  • Treat a connect() timeout as a failure (it resolves with an Error rather than rejecting)
  • Ignore callbacks from a client that has already been replaced

Added tests for the backoff and for stopping discarded clients.

Disable emberplus-connection's internal 5s auto-reconnect and handle retries in the module with exponential backoff (5s -> 60s, reset on connect). Stop discarded clients from retrying forever, and treat a connect() timeout (resolved Error) as a failure.

Co-authored-by: Cursor <cursoragent@cursor.com>
@phillipivan

Copy link
Copy Markdown
Collaborator

Thank you for this.

I am working on some fixes for the ember plus library including its handling of reconnects and will see where that lands before merging.

@phillipivan

Copy link
Copy Markdown
Collaborator

Can you please remove all the reconnect work from this PR now that it is in its own PR. Then I will merge this.

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.

2 participants