inre / rust-mq

RustMQ is the MQTT client written on pure Rust.
MIT License
190 stars 28 forks source link

Client not receiving messages after broker is down and up again #4

Closed tekjar closed 8 years ago

tekjar commented 8 years ago

Slight modification to subscribe example in mqttc

loop {
        match client.await() {
            Ok(result) => {
                match result {
                    Some(message) => println!("{:?}", message),
                    None => println!("."),
                }
            }
            Err(_) => continue,     
        }
    }

Start rust-mq client

RUST_LOG=info,mqttc cargo run --example sub -- 127.0.0.1:1883 a/b/c

Keep publishing with mosquitto_pub

 while true; do sleep 1; mosquitto_pub -t "a/b/c" -m "Hello World"; done

Take down the broker and bring it up again. rust-mq client won't be receiving publishes anymore

inre commented 8 years ago

I fixed this. But it's not whole doing after reconnection. it needs to resend all unacknowledged messages.

tekjar commented 8 years ago

Thanks for this library. I just did another test.

My observations:

Client is not receiving any messages after broker is down (crashed) because all the broker state is gone (persistence not enabled in mosquitto config). I tested client with below config and persitence enabled in broker.

opts.set_client_id("xxxxxx");
opts.set_clean_session(false);

Now I'm receiving messages again after reconnections.