Paho MQTT Python Client: No exceptions thrown, just stops
For anybody who comes across this and wonders why all exceptions inside of a mqtt callback are not thrown or at least not visible: In contrast to the python2 version of paho, the clients already catches ALL exceptions that occur when calling on of the user set callback functions. The output of this catch is then outputted to the on_log callback function. If this is not implemented by the user, there will be no visible output. So just add
def on_log(client, userdata, level, buff):
to your code, in which you can printout the exception descri
This will be due to the fact that the on_message
function is called by the network thread and it will be wrapping that call in a try
block to stop errors in on_message
from stopping that thread.
If you want to an error to stop the app then you should use your own try
block in on_message
and behave appropriately.