eclipse / paho.mqtt.rust

paho.mqtt.rust
Other
527 stars 102 forks source link

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

Open Altair-Bueno opened 2 months ago

Altair-Bueno commented 2 months ago

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