Skip to content

Reusing of MQTT connection (clientId) results in error log "... Never happens." #4014

Closed
@aretap

Description

@aretap

This issue is slightly realated to GH-3685 (#3685).

I am trying to use one MQTT connection with a single clientId for subscriber as well as publisher channels.

Problem is that in MqttConnectOptions is the timeout specified in seconds while in org.eclipse.paho.client.mqttv3.MqttToken.waitForCompletion(long) is expected in milliseconds.

MqttConnectOptions.setConnectionTimeout(int seconds)
client.connect(this.connectionOptions).waitForCompletion(long milliseconds)

So calling:

Mqttv3ClientManager.start() {
  ...
  client.connect(this.connectionOptions).waitForCompletion(this.connectionOptions.getConnectionTimeout());
  ...
}

times out very quickly (default seems to be 30 seconds but they actually time out in 30 milliseconds) and an attempt to call the reconnect() method is made even though the connection is still becoming connected. That results in:

17:17:04,334 ERROR [main] o.s.i.m.c.Mqttv3ClientManager:110 MQTT client failed to connect. Never happens.
Connect already in progress (32110)
        at org.eclipse.paho.client.mqttv3.MqttAsyncClient.reconnect(MqttAsyncClient.java:1399)
        at org.springframework.integration.mqtt.core.Mqttv3ClientManager.start(Mqttv3ClientManager.java:107)
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)

This just prints the error message in log, but the connection seems to be established without further problems and the application works.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions