Skip to content

Injecting the mqtt "client" into more than 10 "<mqtt-connection>"s results in an EventEmitter error message #12

Description

@sandro-k

When creating one <mqtt-connection> element and binding to its client property via <mqtt-connection client='{{client}}'> and then injecting it into another mqtt-connection via <mqtt-connection client='[[client]]'> results in the following error when injected into more than 10 different connection:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use 

This is caused by https://github.com/mqttjs/mqtt-elements/blob/master/mqtt-connection.html#L311 as the element is adding itself as a listener to the client

  client
            .on("close", this._handelClose.bind(this))
            .on("connect", this._handelConnected.bind(this))
            .on("error", this._handelError.bind(this))
            .on("message", this._handelMessage.bind(this))
            .on("offline", this._handelOffline.bind(this))
            .on("reconnect", this._handelReconnect.bind(this));

either the property client.setMaxListeners could be exposed via the <mqtt-connection> or increase client.maxListeners each time mqtt-connection._clientChanged is called.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions