Description
- Version of collectd: 5.8.0-4
- Operating system / distribution: LEDE snapshot (17.01)
Actual behavior
collectd-mod-mqtt plugin hangs when it has to publish more than 20 messages with QoS 1 (it hangs after the 20th). No other messages are being sent afterwards unless collectd is restarted. After a while, the broker will disconnect the client (5minutes I guess).
Steps to reproduce
- configure collectd with some plugins that produce output (memory, df, load, interface, etc) where there should be more than 20 measurements taken.
- configure collectd-mod-mqtt plugin to publish the messages to a broker
- start collectd.
Only 20 messages get sent then everything gets stuck.
I've narrowed it down to mqtt.c file not calling mosquitto_loop() after the call to mosquitto_publish(). It means that the client (collectd-mod-mqtt) will quickly fill out its inflight buffer, since only misquitto_loop() consumes the PUBACK from the broker. By default, libmosquitto has an inflight limit of 20 message (qos 1 or 2) - and without the confirmation from the broker, it will refuse to send more.
I have a small patch ready, but I haven't tested with QoS 2 for now, nor with TLS.