I have been running a mqttsn client publisher/subscriber project (based on the example) successfully for some months. I have added a mosquitto broker to the raspberry pi border router. Each thread node publishes data every 10 seconds.
SDK: nRF5_SDK_for_Thread_and Zigbee_2.0.0
RaspPi image: RaspPi_Thread_Border_Router_Demo_2.0.0-1.alpha
I turned both the raspberry pi and thread node on at the same time several weeks ago. Today, the connection to the broker was lost and cannot be regained. A second thread node with debugger attached shows that the gateway is found, but the connection ( mqttsn_client_connect(&m_client, &m_gateway_addr, m_gateway_id, &m_connect_opt); ) times out repeatedly. I am assuming the Thread network connection is ok, since the gateway was found.
My PC remains connected to the broker on the raspberry pi, but is not receiving any messages. I have repeatedly restarted the node attached to the debugger, and it continues to timeout on the mqtt gateway connection.
This error occurs infrequently (only after running continuously for several weeks). What can I check on the raspberry pi to diagnose the problem?
We have a new SDK and a new border router I suggest that you start using, you can download both here.
About your issue:
Could you try to restart the MQTT-SN Gateway (only the gateway, not the whole Raspberry PI) when this issue occurs, so that we can check if the problem is still there? Should this help you the problem is likely somewhere in the gateway. If this does not work, could you try to restart mosquitto?
I tried killing the MQTT-SNGateway:
sudo kill -9 <PID>
then restar it:
but got an error:
pi@raspberrypi:/etc/init.d $ /usr/sbin/MQTT-SNGatewayterminate called after throwing an instance of 'MQTTSNGW::Exception' what(): Semaphore can't be created.Aborted
I will have to reboot. I will also download the latest image.
I stopped and restarted mosquitto:
then restarted the gateway:
sudo /usr/sbin/MQTT-SNGateway -f paho-mqtt-sn-gateway.conf &
and it ran.
Message publishing is now restored, (but all the messages from the gateway are printing to my raspberry pi console.)
Great to hear that it is working :-)
I have reproduce the problem.
I am at the moment testing the watchdog timer function. To test the timeout function, I comment out the call to feed the watchdog timer so that the timeout and reset occurs after 5 seconds. This happens repeatedly. So, it's rebooting and reconnecting to the mqttsn gateway every 5 seconds.
After a while the gateway starts rejecting the connection. The attached file shows the mqttsn gateway log:
Client "Dal2599e811bfb8c985" is running continuously without rebooting.
Client "Dalcc970a4319322c55 " is rebooting after 5 seconds.
See line 1282 for the first client rejection.
Further down (line 1381), even the node that is not rebooting gets rejected
I know this is not a realistic scenario, but I'd like to know why the gateway starts rejecting ANY connection.
The only recovery is to stop and restart the gateway.