MQTT GW on RPi A drops connection after a while



  • I have built an MQTT GW on an RPi model A based on the sketch provided on the MySensors Build page.
    The settings are as follows:

    ./configure --my-gateway=mqtt --my-controller-url-address=m24.cloudmqtt.com --my-port=18784 --my-mqtt-client-id=sjovsensors --my-mqtt-user=xxxxx --my-mqtt-password=xxxxx --my-mqtt-publish-topic-prefix=sjov-out --my-mqtt-subscribe-topic-prefix=sjov-in --my-transport=rf24 --my-rf24-ce-pin=22 --my-rf24-cs-pin=24 --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18
    

    It all works fine for a while but after an hour or so, no more mqtt messages are transmitted to the broker. The logs do not provide any useful information. Either they show that messages are received and relayed to the broker although they are not, or I am not able to log in to the RPi at all. SSH connection refused. I have tried both cable connect and WLAN connection to the router. The router incidentally is a 3G mobile data connection.

    I suspect that the RPi somehow has lost the link to the broker or the router for a short while and then is unable to reconnect but otherwise I have no clue.

    Ideas welcome!


  • Mod

    @bgunnarb there is no way for the rpi gw to affect your ability to use ssh, so the problem is probably on the network or OS level.
    Does dmesg or syslog say anything around the times when the problem occurs?



  • I suspect the OS or maybe hardware as well. When this happens remote ssh is also broken so difficult to know what is going on. I'll try another RPi. Or maybe an ESP.



  • I recently had alot of issues with my pi gw too. One of the things I found REALLY helped was on my switch I set the speed and duplex to 100mb FULL. In my syslog around the time my GW stopped responding, I was seeing messages about the "carrier lost" on the nic. Not sure what caused that, but it seems like it was taking quite some time to renegotiate. Now that I have it set to 100 FULL my issues have gone from 1-2 a day to only once in 3 weeks.

    Also, make sure you have plenty of power for your PI. I have noticed one of the first things that seems to flake out on me when i have a sub par power supply for the PI is the network.

    Not sure it my experience will help but figured I would try 🙂



  • @crankycoder
    Interesting!
    I am using a mobile broadband connection and it seems to have some issues with drop-outs in the connection. I'll pursue this path first.
    Power should not be an issue. I have a 2.5 A wall-wart supplying the Pi.



  • I did try another RPi but same result.

    I have switched the 3G router to a TP-link Archer MR400 with built-in 3G modem. The 3G connection appears very stable with high signal strength. Still the MQTT MysGW drops out now and then, approx. once every two days. Connection between router and GW is ethernet cable. Since the GW is located abt. 400 km from home, I am not able to troubleshoot effectively.

    So I applied brute force and set up a cron job that restarts mysgw once every 24 hours. This seems to do the trick. I am not disconnected for any longer time than that.

    Strange though that I do not have to restart the RPi. If the issue is caused by the internet connection dropping out, the RPi seems to be able to recover. The GW however seems unable to recover from such a short interruption. So, something similar as @CrankyCoder has experienced.



  • I ended up setting up some monitoring that if by some chance it does go belly up my monitoring will do a recovery action. But it does still happen from time to time, which is strange.


Log in to reply
 

Suggested Topics

  • 3
  • 24
  • 3
  • 2
  • 1
  • 15

26
Online

11.2k
Users

11.1k
Topics

112.5k
Posts