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. Sensor node never reconnects after MQTT gateway reset

Sensor node never reconnects after MQTT gateway reset

Scheduled Pinned Locked Moved Troubleshooting
4 Posts 2 Posters 1.8k Views 2 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.
  • solaS Offline
    solaS Offline
    sola
    wrote on last edited by sola
    #1

    I have built an MQTT client gateway and a humidity node, both of them working properly in normal circumstances.

    Mysensors library: 2.0.0 (downloaded via the Arduino IDE library manager)

    When I power down the ethernet gateway for a couple of minutes and switch it back on, the gateway itself starts up properly but the humidity node will not be able to send messages to it.

    The serial output of the humidity node looks like this:

    TSP:SEND:TNR
    Humidity: 60.20
    !TSP:SEND:TNR
    Humidity: 60.30
    !TSP:SEND:TNR
    Humidity: 60.20
    !TSP:SEND:TNR
    Temperature: 27.30
    !TSM:FPAR:FAIL
    !TSM:FAILURE
    TSM:PDT
    !TSP:SEND:TNR
    Humidity: 60.20
    

    I have waited ~10minutes but no reconnect. The node currently measures / send every 2 seconds.

    The humidity node properly reconnects after a manual reset and after that the newly sent values show up in OpenHAB as well.

    What do I have to do to make the nodes automatically reconnect in a case like this? Since I plan a large number of nodes and some of my nodes will be placed at problematic locations, it is imperative that auto-reconnect happens properly.

    Any help is appreciated.

    1 Reply Last reply
    0
    • solaS Offline
      solaS Offline
      sola
      wrote on last edited by sola
      #2

      With a little digging I have found an other forum topic dealing with the same problem: https://forum.mysensors.org/topic/4381/solved-gatewayesp8266mqttclient-recovery-failure-after-gateway-outage


      I have experimented with the suggestion found there and - in my case - the 1000ms was still not enough for a full reconnect before the node goes to sleep, so I made it 3000ms. This seems to allow a reconnect all the time (at least in my environment).

      I placed the following transport testing/healing code right before the node goes to sleep:

        // @TODO remove after testing gateway outage
        if (!isTransportOK()) {
          #ifdef MY_DEBUG
          Serial.print("Transport ERROR. Waiting for a proper transport reconnect");
          #endif
          wait(3000);
        }
      
      

      I am unsure why MySensors doesn't have this self-healing element built-in. Maybe it is only a bug, maybe it has some deeper reason.

      mfalkviddM 1 Reply Last reply
      0
      • solaS sola

        With a little digging I have found an other forum topic dealing with the same problem: https://forum.mysensors.org/topic/4381/solved-gatewayesp8266mqttclient-recovery-failure-after-gateway-outage


        I have experimented with the suggestion found there and - in my case - the 1000ms was still not enough for a full reconnect before the node goes to sleep, so I made it 3000ms. This seems to allow a reconnect all the time (at least in my environment).

        I placed the following transport testing/healing code right before the node goes to sleep:

          // @TODO remove after testing gateway outage
          if (!isTransportOK()) {
            #ifdef MY_DEBUG
            Serial.print("Transport ERROR. Waiting for a proper transport reconnect");
            #endif
            wait(3000);
          }
        
        

        I am unsure why MySensors doesn't have this self-healing element built-in. Maybe it is only a bug, maybe it has some deeper reason.

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

        @Andras-Soltesz it was something that wasn't considered in the library, so sketch developers need to handle it manually (as you do). In the next version of MySensors sketch developers will not need to handle it manually, thanks to great work by @tekka

        See https://github.com/mysensors/MySensors/pull/558 for details.

        1 Reply Last reply
        0
        • solaS Offline
          solaS Offline
          sola
          wrote on last edited by
          #4

          Great. I added a comment to the GitHub issue to signify its importance.

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


          21

          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