Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

long latency to set up connections when creating multiple connected clients #217

Open
zhen9910 opened this issue Dec 6, 2023 · 1 comment

Comments

@zhen9910
Copy link

zhen9910 commented Dec 6, 2023

When creating multiple mqtt connections using paho-mqtt, version "0.12", some of connections takes more than 1s to be established.

This is a similar issue reported in #133 and eclipse-paho/paho.mqtt.cpp#365, but it looks appear again.

Could you take a look? It can be reproduced using the same test code in #133.

fn create_connected_client() -> paho_mqtt::AsyncClient {
    const MQTT_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(1);
    let start_of_create = std::time::Instant::now();
    let create_opts = paho_mqtt::CreateOptionsBuilder::new()
        .server_uri("tcp://localhost:1883")
        .finalize();
    let mqtt_client = paho_mqtt::AsyncClient::new(create_opts).unwrap();
    let conn_opts = paho_mqtt::ConnectOptionsBuilder::new().finalize();
    let _ = mqtt_client.connect(conn_opts).wait_for(MQTT_TIMEOUT);
    println!(
        "It took {:?} until client was connected",
        start_of_create.elapsed()
    );
    mqtt_client
}

fn main() {
    let cli_1 = create_connected_client();
    let cli_2 = create_connected_client();
    let cli_3 = create_connected_client();
    let cli_5 = create_connected_client();
    let cli_6 = create_connected_client();
}

It took 116.445807ms until client was connected
It took 1.000388665s until client was connected
It took 1.000957073s until client was connected
It took 102.734703ms until client was connected
It took 1.000762798s until client was connected

@JinyongJeong-TIM
Copy link

JinyongJeong-TIM commented Sep 27, 2024

I have this issue as well with latest version of c++

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants