org.eclipse.paho.client.mqttv3.MqttException: Client is connected

Spring JIRA | Anton | 11 months ago
  1. 0

    Details: Mqtt broker: apache apollo 1.7 Mqtt eclipse paho client There is some logic on our server that constructs outbound (response) topic name based on incoming message topic name. The logic is pretty straightforward. Client sends message to the topic name {{path/<device-id>/<sub-device-id>/outbound}} and gets server echo message on {{path/<device-id>/<sub-device-id>/inbound}} topic. We didn't implement any topic validation logic on server side yet and this causes the next issue: When some device (not in our control) sends message to the topic name {{path/\+/\+/outbound}} (which is wrong topic name format) server constructs the next topic name for the response message: {{path/\+/\+/inbound}}. The topic name to send message is obviously invalid and after _multiple attempts_ to send message to this topic name system hangs at {{MqttPahoMessageDrivenChannelAdapter}} with the message "Attempting reconnect". The log contains the following exceptions + {{MqttPahoMessageDrivenChannelAdapter}} becomes running in the loop trying to re-connect to mqtt broker: {noformat} org.springframework.messaging.MessageHandlingException: error occurred in message handler [mqttOutboundHandler]; nested exception is java.lang.IllegalArgumentException: The topic name MUST NOT contain any wildcard characters (#+) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:139) at org.springframework.integration.config.annotation.ServiceActivatorAnnotationPostProcessor$ReplyProducingMessageHandlerWrapper.handleRequestMessage(ServiceActivatorAnnotationPostProcessor.java:99) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ................ org.eclipse.paho.client.mqttv3.MqttException: Client is connected at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.connect(MqttAsyncClient.java:465) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.connect(MqttAsyncClient.java:455) at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.connectAndSubscribe(MqttPahoMessageDrivenChannelAdapter.java:194) at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.access$300(MqttPahoMessageDrivenChannelAdapter.java:41) at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter$1.run(MqttPahoMessageDrivenChannelAdapter.java:237) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 2015-12-21 16:02:28.362 DEBUG 65151 --- [task-scheduler-1] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:28.364 DEBUG 65151 --- [task-scheduler-4] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:33.697 DEBUG 65151 --- [task-scheduler-8] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:37.898 DEBUG 65151 --- [task-scheduler-6] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:37.900 DEBUG 65151 --- [task-scheduler-9] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:37.921 DEBUG 65151 --- [task-scheduler-2] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:38.024 DEBUG 65151 --- [task-scheduler-7] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect ............... {noformat} indefinitely trying to reconnect. We can definitely fix this issue on our server side to validate topic names but there is still open question why {{MqttPahoMessageDrivenChannelAdapter}} : Attempting reconnect appears on paho {{java.lang.IllegalArgumentException: The topic name MUST NOT contain any wildcard characters (#+)}} in general? And more important question why channel adapter hangs on attempts to reconnect?

    Spring JIRA | 11 months ago | Anton
    org.eclipse.paho.client.mqttv3.MqttException: Client is connected
  2. 0

    Details: Mqtt broker: apache apollo 1.7 Mqtt eclipse paho client There is some logic on our server that constructs outbound (response) topic name based on incoming message topic name. The logic is pretty straightforward. Client sends message to the topic name {{path/<device-id>/<sub-device-id>/outbound}} and gets server echo message on {{path/<device-id>/<sub-device-id>/inbound}} topic. We didn't implement any topic validation logic on server side yet and this causes the next issue: When some device (not in our control) sends message to the topic name {{path/\+/\+/outbound}} (which is wrong topic name format) server constructs the next topic name for the response message: {{path/\+/\+/inbound}}. The topic name to send message is obviously invalid and after _multiple attempts_ to send message to this topic name system hangs at {{MqttPahoMessageDrivenChannelAdapter}} with the message "Attempting reconnect". The log contains the following exceptions + {{MqttPahoMessageDrivenChannelAdapter}} becomes running in the loop trying to re-connect to mqtt broker: {noformat} org.springframework.messaging.MessageHandlingException: error occurred in message handler [mqttOutboundHandler]; nested exception is java.lang.IllegalArgumentException: The topic name MUST NOT contain any wildcard characters (#+) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:139) at org.springframework.integration.config.annotation.ServiceActivatorAnnotationPostProcessor$ReplyProducingMessageHandlerWrapper.handleRequestMessage(ServiceActivatorAnnotationPostProcessor.java:99) at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:99) at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:127) ................ org.eclipse.paho.client.mqttv3.MqttException: Client is connected at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.connect(MqttAsyncClient.java:465) at org.eclipse.paho.client.mqttv3.MqttAsyncClient.connect(MqttAsyncClient.java:455) at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.connectAndSubscribe(MqttPahoMessageDrivenChannelAdapter.java:194) at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.access$300(MqttPahoMessageDrivenChannelAdapter.java:41) at org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter$1.run(MqttPahoMessageDrivenChannelAdapter.java:237) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) 2015-12-21 16:02:28.362 DEBUG 65151 --- [task-scheduler-1] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:28.364 DEBUG 65151 --- [task-scheduler-4] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:33.697 DEBUG 65151 --- [task-scheduler-8] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:37.898 DEBUG 65151 --- [task-scheduler-6] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:37.900 DEBUG 65151 --- [task-scheduler-9] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:37.921 DEBUG 65151 --- [task-scheduler-2] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect 2015-12-21 16:02:38.024 DEBUG 65151 --- [task-scheduler-7] .m.i.MqttPahoMessageDrivenChannelAdapter : Attempting reconnect ............... {noformat} indefinitely trying to reconnect. We can definitely fix this issue on our server side to validate topic names but there is still open question why {{MqttPahoMessageDrivenChannelAdapter}} : Attempting reconnect appears on paho {{java.lang.IllegalArgumentException: The topic name MUST NOT contain any wildcard characters (#+)}} in general? And more important question why channel adapter hangs on attempts to reconnect?

    Spring JIRA | 11 months ago | Anton
    org.eclipse.paho.client.mqttv3.MqttException: Client is connected
  3. 0

    MQTT binding slow/hangs on startup

    Google Groups | 3 years ago | Ben Jones
    org.eclipse.paho.client.mqttv3.MqttException: Client is not connected*
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Catch client is disconnected using the V3.1 protocol.

    GitHub | 10 months ago | jpwsutton
    org.eclipse.paho.client.mqttv3.MqttException: Client is disconnected Client is disconnected (32101)
  6. 0

    MQTT connection gets stale / does not refresh

    GitHub | 3 years ago | petrklus
    org.eclipse.paho.client.mqttv3.MqttException: Client is disconnected

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.eclipse.paho.client.mqttv3.MqttException

      Client is connected

      at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException()
    2. org.eclipse.paho
      MqttAsyncClient.connect
      1. org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:31)
      2. org.eclipse.paho.client.mqttv3.MqttAsyncClient.connect(MqttAsyncClient.java:465)
      3. org.eclipse.paho.client.mqttv3.MqttAsyncClient.connect(MqttAsyncClient.java:455)
      3 frames
    3. org.springframework.integration
      MqttPahoMessageDrivenChannelAdapter$1.run
      1. org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.connectAndSubscribe(MqttPahoMessageDrivenChannelAdapter.java:194)
      2. org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter.access$300(MqttPahoMessageDrivenChannelAdapter.java:41)
      3. org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter$1.run(MqttPahoMessageDrivenChannelAdapter.java:237)
      3 frames
    4. Spring Context
      DelegatingErrorHandlingRunnable.run
      1. org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
      1 frame
    5. Java RT
      Thread.run
      1. java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      2. java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
      3. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
      4. java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      5. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      6. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      7. java.lang.Thread.run(Thread.java:745)
      7 frames