简体   繁体   中英

Does mosquitto broker send disconnect message upon shutdown?

I am using MQTT broker configured on a host machine with Windows 2012 server OS and a few embedded devices are subscribed to broker to receive commands.

I wanted to understand, does MQTT broker send any disconnect message to all its subscribed clients when the broker service on host machine stops because of any reason like the host machine is rebooted or shutdown. The reason I ask this question is below.

On my device, all the code (including mqtt client library)stops executing when device goes to sleep, and execution does not resume until device is woken up (by receiving data packet on WiFi channel or by a few other actions).

Now when I reboot the host machine, I am observing that my devices are waking up from sleep and are trying to reconnect to broker until MQTT broker is coming back. I think the devices are waking up only because they are receiving some data over WiFi channel because I am not taking any other action which could wake up the device.

So I am wondering what is that WiFi data packet that is waking up the device and causing the device to reconnect. Is it probably a disconnect command sent by Broker to the device?

No, the broker will not send any messages on shutdown. The MQTT Disconnect Message is only sent from the client to broker according to the spec.

I suggest you install some network monitoring software (eg Wireshark) to track what network activity is happening.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM