Dave, The logs show no positive indication of a cause for the thread to fail.
However, we can see that the thread died between publishing the first value to the first topic and publishing the second value to the second topic, this is a closed loop publishing each value in the packet to a separate topic in turn.
There is no evidence of any out of range values, wrong datatypes or missing values etc so there is no evident reason for the mqtt interfacer to crash mid loop.
This would possibly point to a unhandled MQTT connection type error, the reason the “RFM2Pi” thread has crashed is because the MQTT code is incorrectly running from within the RFM2Pi thread, so when there is an MQTT issue it brings down both the MQTT and RFM2Pi threads, @TrystanLea is aware of this and it is on the hit list to be dealt with and unlikely to be the cause of the fail (although I cannot be sure). All “RFM2Pi” activity is blocked until all the MQTT is published so it cannot be the RFM2Pi code. This was proved a while back with the addition of the “Sent to channel(start)” and “Sent to channel(end)” messages.
As expected, it looks very much like the MQTT implementation, either internal or external to emonhub is the place to be looking.
It reaches and runs this line without a problem
But fails to reach that same point in the next loop, given it successfully reached that point once, we might assume it should be able to again, so that might suggest the issue is in the remaining part of the loop rather than in the beginning of the next. very loose assumptions but we need start somewhere.
Therefore you could try editing ~/emon-pi/src/interfacers/EmonHubMqttInterfacer.py and add a try/except to the next line (L126) so it looks like so
try:
result =self._mqttc.publish(topic, payload=payload, qos=2, retain=False)
except Exception as e:
self._log.warning("Unable to publish: "+topic+" "+payload+" error: "+ str(e))
and see if that uncovers anything.
See my comments in post #7 of the “Emonhub minor code cleanup, enhancements and python3 support” thread about adding some tracebacks and restarting threads internally to emonhub.