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

Reconnect timeout needed (or eliminate reconnects) #11

Open
tagdara opened this issue Nov 6, 2023 · 0 comments
Open

Reconnect timeout needed (or eliminate reconnects) #11

tagdara opened this issue Nov 6, 2023 · 0 comments

Comments

@tagdara
Copy link

tagdara commented Nov 6, 2023

A reconnect is attempted on a ECONNRESET without any throttling, causing a potential DOS of the elk device. This is causing downstream issues seen in homebridge-elkm1.

paulw11/homebridge-elkm1#35

I'm not sure, based on other use cases for elkmon, whether a throttle or a removal of the single use case retry would be better, but it should be consistent across errors and have a way to prevent overloading the device. Even adding a 5 second timeout before the retry would prevent most negative effects.

    // error event handler
    this.connection.on('error', (err) => {
      if (err.code === 'ECONNREFUSED') {
        this.emit('error', 'Connection to M1XEP failed!');
      } else if (err.code === 'ECONNRESET') {
        this.emit('error', err.code);
        // connection was reset, attempt to reconnect
        if (this.connection) {
          this.connection.destroy();
        }
        this.connect();
      } else {
        this.emit('error', err.code);
      }
    });
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

No branches or pull requests

1 participant