Failing on_message
retries message indefinitly
#867
Labels
Status: Available
No one has claimed responsibility for resolving this issue.
Hi!
I was trying to understand the behaviour of message processing if
on_message
fails with respect to package acknowledgement. Ifon_message
fails, then the message is not acknowledged and I was pondering how this will affect the client. What I found surprised me.If
on_message(...)
fails, then the message is kept in the client and retried (by the client) as soon as an other message is received. If it fails again, then the message is retried indefinitly and the client fails to process any new messages. Eventually, this causes a connection timeout. Even after the timeout, the message is retried indefinitly.I was expecting that if
on_messsage(...)
fails, then the message is dropped.Furthermore, I was expecting that if
on_message(...)
fails on QoS 1 and 2 messages, then the message should still be acknowledged as it was passed from the client to the software. The client might fail to send an acknowledgment due to external reasons, e. g., network issues.So, what is the reason behind this behaviour?
Note that I was expecting the behaviour similar to
suppress_exceptions = True
only that the expceptions are passed through.How to reproduce
Start your mqtt broker. You can use the docker compose and mosquitto configuration below.
Start the script below.
Send a message to
t/qos_0
andt/qos_1
, respectivly:mosquitto_pub -t qos=0 -m "msg_1" -q 0 -V mqttv5
The client below reuses the mqtt session. So if a QoS 1 message fails to process and the client restarts, the message is retried and the client is thus stuck in a loop immediatly.
docker-compose.yml
mosquitto.conf
Environment
The text was updated successfully, but these errors were encountered: