mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

mosquitto_disconnect stops the network loop but mosquitto_connect doesn't start it.

Open andrewwade opened this issue 3 years ago • 0 comments

This is more of an unexpected behavior on my part and maybe I just haven't found the right documentation.

I assumed I could call the following sequence and the client would just resume running the loop after the second connect.

mosquitto_loop_start(mosq);
mosquitto_connect_async(mosq);
sleep(10);
mosquitto_disconnect(mosq);
sleep(10);
mosquitto_connect_async(mosq);
sleep(10);
mosquitto_loop_stop(mosq);

But instead, I have to call mosquitto_loop_start again after mosquitto_disconnect. Otherwise I won't get the connect callback on the second mosquitto_connect_async.

I believe it's because of the following lines: https://github.com/eclipse/mosquitto/blob/master/lib/loop.c#L297-L298 https://github.com/eclipse/mosquitto/blob/master/lib/loop.c#L320-L321

Mosquitto Version: 2.0.14

andrewwade avatar Jun 22 '22 17:06 andrewwade