HankB / MQTT_will

Use MQTT last will and testament to monitor host up.
MIT License
0 stars 0 forks source link

no reconnect if broker bounces #1

Open HankB opened 2 years ago

HankB commented 2 years ago

At one point in time the broker stopped distributing all messages. It's Docker container was restarted and traffic resumed, but mosquito_pub used in this script never reconnected.

HankB commented 2 years ago

Performed some testing using a mosquitto_pub connection to localhost (default) and explicitly providing the broker host name. Test performed was:

  1. broker started.
  2. subscribe to all messages
  3. start client with 30s interval ./MQTT_will.sh -b rocinante -i 30
  4. wait for still connected message
  5. stop the broker
  6. wait a minute
  7. start broker

Results. At step 5, the subscriber received the will message. At step 7 the client immediately received the still connected message and subsequent to that received more still connected messages.

Conclusion: mosquitto_pub (and mosquitto_sub) will both reconnect if the broker is bounced. In this test case there was an orderly shutdown. Possible situation with this bug is that the broker hung rather than stopped. If the situation recurs, one test to perform would be to try to subscribe to the broker before bouncing it.