hivemq / hivemq-mqtt-client

HiveMQ MQTT Client is an MQTT 5.0 and MQTT 3.1.1 compatible and feature-rich high-performance Java client library with different API flavours and backpressure support
https://hivemq.github.io/hivemq-mqtt-client/
Apache License 2.0
832 stars 153 forks source link

Disconnection during subscription is not propagated #551

Open guillaumelamirand opened 1 year ago

guillaumelamirand commented 1 year ago

Expected behavior

When a disconnection occurred after a successful connection and during subscription, and if there is no more reconnect attempt expected, the error should be propagated as it does if the same error occurred during the initial connection.

Actual behavior

Currently the error is not propagated because when an error occurred after a successful connection, the obverser is null in MqttConnAckFlow, l69.

image

To Reproduce

Steps

  1. Create a container with the hivemq/hivemq4:latest image
  2. Implement a simple client with this extra disconnected listener that will reconnect 3 times and then should propagate an error
    .addDisconnectedListener(context -> {
                if (context.getReconnector().getAttempts() >= 3) {
                    context.getReconnector().reconnect(false);
                }
            });
  3. DO NOT START the hivemq container and run you client, after few seconds (3 reconnections attempt) you will get an error as expected
  4. Start the hivemq container
  5. Run you client which should connect successfully
  6. Stop the hivemq container
  7. You will see that the 3 attempts are done as expected butthen the parent observer being null, nothing else happens.

Details