Skip to content

Connecting twice to the same broker causes AsyncClient to get stuck #234

@Altair-Bueno

Description

@Altair-Bueno

MRE

use paho_mqtt::AsyncClient;
use paho_mqtt::ConnectOptionsBuilder;
use paho_mqtt::CreateOptions;
use paho_mqtt::Error;

#[tokio::main]
async fn main() -> Result<(), Error> {
    let client = AsyncClient::new(CreateOptions::default())?;

    println!("First one connecting");
    client
        .connect(
            ConnectOptionsBuilder::new()
                .server_uris(&["test.mosquitto.org:1883"])
                .finalize(),
        )
        .await?;
    println!("Fist one connected");

    println!("Second one connecting");
    client
        .connect(
            ConnectOptionsBuilder::new()
                .server_uris(&["test.mosquitto.org:1883"])
                .finalize(),
        )
        .await?;
    println!("Second one connected");

    Ok(())
}
First one connecting
Fist one connected
Second one connecting

repr-async-client-stuck-double-connect.zip

Current behavior

Connecting twice to the same broker causes AsyncClient to get stuck on the second connect call.

Expected behaviour

Second connect call should be ignored, as it is already connected.

Additional information

Setting different protocols doesn't change anything

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions