eclipse / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.12k stars 883 forks source link

manual acknowledgement results in duplicate pubcomp #1054

Open whizyrel opened 1 month ago

whizyrel commented 1 month ago

Please fill out the form below before submitting, thank you!

If this is a bug regarding the Android Service, please raise the bug here instead: https://github.com/eclipse/paho.mqtt.android/issues/new

ISSUE DESCRIPTION Setting manual acknowledgement to true and calling the message arrived complete method results into duplicate pubcomp and the connection gets disconnected. In short, manual acknowledgement is not possible.

SNIPPET TO REPRODUCE


var client = ...;

client.setManualAcks(true);

client.setCallback(new MqttCallback() {
   ...
   @Override
   public void messageArrived(String topic, MqttMessage message) {
      ...
      client.messageAriveComplete(message.getId(), 2);
      ...
   }
   ...
});

client.subscribe(...);

Result

Creating MqttPubComp due to manual ACK: MqttPubComp [returnCode=0, properties=MqttProperties [validProperties=[...]]]
Creating MqttPubComp: MqttPubComp [returnCode=0, properties=MqttProperties [validProperties=[...]]]
MqttDisconnectResponse [returnCode=0, reasonString=null, userProperties=null, serverReference=null, exception=Connection lost (32109) - java.net.SocketException: Connection reset]