Skip to content

Async MQTT client blocks on publish if the client is disconnected and waiting between reconnect attempts #554

Open
@richturner

Description

@richturner

Expected behavior

The async client (in my case Mqtt3AsyncClient) should not block when calling send no matter what the client state is; instead I would expect to get the CompletableFuture<MqttPublish>

Actual behavior

send blocks the calling thread; I guess waiting for the client to be in a connected state?

To Reproduce

  1. Create an Mqtt3AsyncClient with reconnect logic, put an invalid host value (so the client can never actually connect)
  2. Publish an MQTT message e.g.:
client.publishWith()
            .topic(message.topic)
            .payload(messageToBytes(message.payload))
            .send()
            .whenComplete((publish, throwable) -> {
                if (throwable != null) {
                    // Failure
                    LOG.log(Level.INFO, "Failed to publish to MQTT broker '" + getClientUri() + "'", throwable);
                } else {
                    // Success
                    LOG.finer("Published message to MQTT broker '" + getClientUri() + "'");
                }
            });
  1. Notice that the call blocks on the send call with no Future ever returned

Details

  • Affected HiveMQ MQTT Client version(s): 1.2.2
  • Used JVM version: Oracle JDK 17.0.1
  • Used OS (name and version): Windows 10 64-bit but also same behaviour on Linux Debian AArch64
  • Used MQTT version: N/A
  • Used MQTT broker (name and version): N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions