Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Troubleshooting
  3. MQTT GW on RPi A drops connection after a while

MQTT GW on RPi A drops connection after a while

Scheduled Pinned Locked Moved Troubleshooting
7 Posts 3 Posters 826 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • bgunnarbB Offline
    bgunnarbB Offline
    bgunnarb
    wrote on last edited by
    #1

    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!

    I have never been so busy since I retired!

    mfalkviddM 1 Reply Last reply
    0
    • bgunnarbB bgunnarb

      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!

      mfalkviddM Online
      mfalkviddM Online
      mfalkvidd
      Mod
      wrote on last edited by
      #2

      @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?

      1 Reply Last reply
      0
      • bgunnarbB Offline
        bgunnarbB Offline
        bgunnarb
        wrote on last edited by
        #3

        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 have never been so busy since I retired!

        1 Reply Last reply
        0
        • CrankyCoderC Offline
          CrankyCoderC Offline
          CrankyCoder
          wrote on last edited by
          #4

          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 :)

          Home Automation Tinkerer
          www.CrankyCoder.net

          Controller: HomeAssistant in Kubernetes
          Gateway: MQTTClientGateway
          MySensors: 2.3

          bgunnarbB 1 Reply Last reply
          1
          • CrankyCoderC CrankyCoder

            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 :)

            bgunnarbB Offline
            bgunnarbB Offline
            bgunnarb
            wrote on last edited by
            #5

            @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 have never been so busy since I retired!

            1 Reply Last reply
            1
            • bgunnarbB Offline
              bgunnarbB Offline
              bgunnarb
              wrote on last edited by
              #6

              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 have never been so busy since I retired!

              1 Reply Last reply
              1
              • CrankyCoderC Offline
                CrankyCoderC Offline
                CrankyCoder
                wrote on last edited by
                #7

                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.

                Home Automation Tinkerer
                www.CrankyCoder.net

                Controller: HomeAssistant in Kubernetes
                Gateway: MQTTClientGateway
                MySensors: 2.3

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                29

                Online

                11.7k

                Users

                11.2k

                Topics

                113.1k

                Posts


                Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • MySensors
                • OpenHardware.io
                • Categories
                • Recent
                • Tags
                • Popular