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

Prevent an ECONNRESET storm when accessories turn off #197

Merged
merged 1 commit into from
Feb 15, 2021

Conversation

davidh2075
Copy link
Contributor

To prevent a fast ECONNRESET loop when turning off an accessory and turning it back on more than a few minutes later, e.g. to move and re-purpose it, did the following: In _socket.on('error') recorded the _connect() Timeout in this._socket._errorReconnect and tested that value before setting another Timeout to prevent scheduling two _connect() calls; Added _errorReconnect to the list of Timeouts cleared in _connect(); In this._socket.reconnect, incremented the Attempt Counter this._connectionAttempts just before the call to this._socket.connect(). The attempt counter was being incremented only on _connect(), not on reconnect; In _socket.on('connect'), cleared an existing pinger Timeout before setting another one; Added several DEBUG console.log statements to help trace what was happening and confirm the above changes worked.

…urning it back on more than a few minutes later, e.g. to move and re-purpose it, did the following: In _socket.on('error') recorded the _connect() Timeout in this._socket._errorReconnect and tested that value before setting another Timeout to prevent scheduling two _connect() calls; Added _errorReconnect to the list of Timeouts cleared in _connect(); In this._socket.reconnect, incremented the Attempt Counter this._connectionAttempts just before the call to this._socket.connect(). The attempt counter was being incremented only on _connect(), not on reconnect; In _socket.on('connect'), cleared an existing pinger Timeout before setting another one; Added several DEBUG console.log statements to help trace what was happening and confirm the above changes worked.
@iRayanKhan iRayanKhan merged commit 954cec9 into iRayanKhan:main Feb 15, 2021
pauldev20 pushed a commit to pauldev20/homebridge-tuya that referenced this pull request Jun 11, 2024
Prevent an ECONNRESET storm when accessories turn off
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