Spring MqttPahoMessageDrivenChannelAdapter Lost connection:Connection lost; retrying

前端 未结 2 1868
庸人自扰
庸人自扰 2021-01-14 20:06

We are using Spring message-driven-channel-adapter to subscribe MQTT topic. But we are getting below error very frequently. I have tes

相关标签:
2条回答
  • 2021-01-14 20:32

    Just wanted to share in case it helps... I had the same exception and fixed it by ensuring a unique client ID was generated (with MqttAsyncClient.generateClientId()), as mentioned here: https://github.com/eclipse/paho.mqtt.java/issues/207#issuecomment-338246879

    0 讨论(0)
  • 2021-01-14 20:43

    But you are still not really describing a problem. You show a message above so it must be working for you. Paho is detecting a connection problem; it informs Spring Integration which will reconnect.

    You can get complete information about the exception by adding an ApplicationListener to your application.

    @Bean
    public ApplicationListener<?> eventListener() {
        return new ApplicationListener<MqttConnectionFailedEvent>() {
    
            @Override
            public void onApplicationEvent(MqttConnectionFailedEvent event) {
                event.getCause().printStackTrace();
            }
    
        };
    }
    

    Result:

    Connection lost (32109) - java.io.EOFException
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:164)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: java.io.EOFException
        at java.io.DataInputStream.readByte(DataInputStream.java:267)
        at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92)
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:116)
        ... 1 more
    

    (when I shut down the broker).

    If you think there's a problem with the paho client, you should raise an issue for that project.

    0 讨论(0)
提交回复
热议问题