eclipse / paho.mqtt.rust

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

async client reconnect #146

Closed srbpavel closed 10 months ago

srbpavel commented 2 years ago

Dear, please with blocking sync Client i'am able to client.reconnect().is_ok() when testing mosquitto broker restart or what ever.

But with async AsyncClient and token i did not make it recover:

i have tested it also with your mqtt_chat example as following:

cli.set_connection_lost_callback(|client| {
    let mut reconnect_counter = 0;

    loop {

        reconnect_counter += 1;
        println!("reconnect counter: {reconnect_counter}");

         let server_response = client
            .reconnect()
               .try_wait();

           println!("ServerResponse: {server_response:?}");

this is what i receive: Some(Err(PahoDescr(-18, "Unknown Error")))

my settings is the same as in your example. tcp protocol + mqttv 5 .... and only added user/pass in ConnectOptionsBuilder

did i understand the reconnect in async client correctly?

thank you pavel

Tockra commented 1 year ago

Did you find a solution?

srbpavel commented 1 year ago

Did you find a solution?

honestly i do not remember, probably i have choose a different way. this was my first try with mqtt_paho https://github.com/srbpavel/rust/blob/main/mqtt_client/src/lib.rs

fpagliughi commented 1 year ago

Sorry. It looks like a bug in the upstream Paho C library is causing havoc on reconnect, which send to result in bad pointer being passed around. It manifests in a number of ways, including segfaults, double free errors, and this, apparently.

The next release will get it fixed.

mushonnip commented 1 year ago

Sorry. It looks like a bug in the upstream Paho C library is causing havoc on reconnect, which send to result in bad pointer being passed around. It manifests in a number of ways, including segfaults, double free errors, and this, apparently.

The next release will get it fixed.

Has this been fixed now? I had the same experience. I hope the next version will be released soon.

fpagliughi commented 10 months ago

It looks like this is fixed with the upcoming v0.12.3 release. At least I can't recreate it in testing. If you still see it with that version, please feel free to reopen.