emqx / mqtt-jmeter

MQTT JMeter Plugin
https://www.emqx.com/en
Apache License 2.0
445 stars 194 forks source link

Auto reconnect does not work with authentication or if the reconnect max attempts is set to -1 #136

Closed mariusstaicu closed 11 months ago

mariusstaicu commented 1 year ago

When trying to use auto reconnect feature with the mqtt-plugin, it does not work for the hivemq client implementation in the following 2 scenarios:

  1. when setting max reconnect attempts to -1 (infinite) it does not work because of this piece of code in HiveMQTTClient:
    if (parameters.getReconnectMaxAttempts() > 0) {
        builder = builder.automaticReconnectWithDefaultConfig();
    }
  1. when using authentication, the mqtt reconnector does not inherit the credentials used at the initial connection, because those are set when connection is made and not when client is initially configured. In order for the MqttClientReconnector to inherit the authentication, it is necessary to configure authentication prior to configuring the automatic reconnect.
chongyuanyin commented 11 months ago

Thanks!