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. General Discussion
  3. [SOLVED] Strange behavior on MQTT Gateway Reset

[SOLVED] Strange behavior on MQTT Gateway Reset

Scheduled Pinned Locked Moved General Discussion
13 Posts 4 Posters 1.7k Views 4 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.
  • X xefil

    Hi all,

    I'm noticing a strange behavior on my Mqtt Gateway Client. It was on 2.0 version, updated to latest AFTER noticing this strange behavior. As soon the MySensors MQTT Gateway client gets reset, I can see those log entries:

    Mon Dec 24 15:52:52 2018: New connection from 192.168.1.51 on port 1883.
    Mon Dec 24 15:52:53 2018: Client mysensors-1 already connected, closing old connection.
    Mon Dec 24 15:52:53 2018: Socket error on client mysensors-1, disconnecting.
    Mon Dec 24 15:52:53 2018: New client connected from 192.168.1.51 as mysensors-1 (c1, k15).
    Mon Dec 24 15:52:53 2018: No will message specified.
    Mon Dec 24 15:52:53 2018: Sending CONNACK to mysensors-1 (0, 0)
    Mon Dec 24 15:52:53 2018: Received PUBLISH from mysensors-1 (d0, q0, r0, m0, 'mygateway1-out/0/255/0/0/18', ... (5 bytes))
    Mon Dec 24 15:52:53 2018: Sending PUBLISH to home-assistant-1 (d0, q0, r0, m0, 'mygateway1-out/0/255/0/0/18', ... (5 bytes))
    Mon Dec 24 15:52:53 2018: Received SUBSCRIBE from mysensors-1
    Mon Dec 24 15:52:53 2018:       mygateway1-in/+/+/+/+/+ (QoS 0)
    Mon Dec 24 15:52:53 2018: mysensors-1 0 mygateway1-in/+/+/+/+/+
    Mon Dec 24 15:52:53 2018: Sending SUBACK to mysensors-1
    Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/28/1/1/0/2', ... (1 bytes))
    Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/28/255/3/0/6', ... (1 bytes))
    Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/20/1/1/0/2', ... (1 bytes))
    Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/30/1/1/0/2', ... (1 bytes))
    Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/30/255/3/0/6', ... (1 bytes))
    

    I can simulate it with a manual reset as well. mysensors-1 is the MySensors MQTT Client.
    So, why it's resetting is something I need to understand. Now, after update, seems more stable.
    But what I cannot understand is why immediate after the reset, the MQTT MySensors Gateway is getting some publish commands. One of this atcivate a relay, and it's not funny that it's activated every reset.
    I've moved to HomeAssistant from OpenHAB2, but cannot tell it's related. I have not an exactly idea what that happens.
    MQTT Server 1.5.5-0mosquitto1.

    Ideas?

    Thanks and Happy Holidays!

    Simon

    electrikE Offline
    electrikE Offline
    electrik
    wrote on last edited by
    #2

    @xefil it looks like these publish commands are retained messages, and the broker sends them upon reconnection
    See http://www.steves-internet-guide.com/mqtt-retained-messages-example/

    1 Reply Last reply
    0
    • X xefil

      Hi all,

      I'm noticing a strange behavior on my Mqtt Gateway Client. It was on 2.0 version, updated to latest AFTER noticing this strange behavior. As soon the MySensors MQTT Gateway client gets reset, I can see those log entries:

      Mon Dec 24 15:52:52 2018: New connection from 192.168.1.51 on port 1883.
      Mon Dec 24 15:52:53 2018: Client mysensors-1 already connected, closing old connection.
      Mon Dec 24 15:52:53 2018: Socket error on client mysensors-1, disconnecting.
      Mon Dec 24 15:52:53 2018: New client connected from 192.168.1.51 as mysensors-1 (c1, k15).
      Mon Dec 24 15:52:53 2018: No will message specified.
      Mon Dec 24 15:52:53 2018: Sending CONNACK to mysensors-1 (0, 0)
      Mon Dec 24 15:52:53 2018: Received PUBLISH from mysensors-1 (d0, q0, r0, m0, 'mygateway1-out/0/255/0/0/18', ... (5 bytes))
      Mon Dec 24 15:52:53 2018: Sending PUBLISH to home-assistant-1 (d0, q0, r0, m0, 'mygateway1-out/0/255/0/0/18', ... (5 bytes))
      Mon Dec 24 15:52:53 2018: Received SUBSCRIBE from mysensors-1
      Mon Dec 24 15:52:53 2018:       mygateway1-in/+/+/+/+/+ (QoS 0)
      Mon Dec 24 15:52:53 2018: mysensors-1 0 mygateway1-in/+/+/+/+/+
      Mon Dec 24 15:52:53 2018: Sending SUBACK to mysensors-1
      Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/28/1/1/0/2', ... (1 bytes))
      Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/28/255/3/0/6', ... (1 bytes))
      Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/20/1/1/0/2', ... (1 bytes))
      Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/30/1/1/0/2', ... (1 bytes))
      Mon Dec 24 15:52:53 2018: Sending PUBLISH to mysensors-1 (d0, q0, r1, m0, 'mygateway1-in/30/255/3/0/6', ... (1 bytes))
      

      I can simulate it with a manual reset as well. mysensors-1 is the MySensors MQTT Client.
      So, why it's resetting is something I need to understand. Now, after update, seems more stable.
      But what I cannot understand is why immediate after the reset, the MQTT MySensors Gateway is getting some publish commands. One of this atcivate a relay, and it's not funny that it's activated every reset.
      I've moved to HomeAssistant from OpenHAB2, but cannot tell it's related. I have not an exactly idea what that happens.
      MQTT Server 1.5.5-0mosquitto1.

      Ideas?

      Thanks and Happy Holidays!

      Simon

      YveauxY Offline
      YveauxY Offline
      Yveaux
      Mod
      wrote on last edited by
      #3

      @xefil said in Strange behavior on MQTT Gateway Reset:

      Now, after update, seems more stable.

      MySensors 2.3.1 contains the latest PubSubClient 2.7 (see https://github.com/knolleary/pubsubclient/releases)
      Amongst other issues it fixes a buffer overrun bug. I also had issues with older PubSubClient releases that seem to be fixed with 2.7.

      http://yveaux.blogspot.nl

      1 Reply Last reply
      0
      • X Offline
        X Offline
        xefil
        wrote on last edited by
        #4

        Hello @electrik and @Yveaux ; thanks for the answers.
        It's still not totally clear who is retaining those messages.
        It's a mosquitto issue, an issue from the Controller (OpenHAB2 or HomeAssistant) or a driver issue from MySensors?
        BTW, the last case, having updated the MQTT Mysensors gateway as well as the affected sensor leaf, I would discard this last option.
        I need to understand as well how to read the debug messages from mosquitto. It doesn't contain the message value and have no idea if the retain flag is set or not :-) I know that's a little off topic :-)
        Any further help is appreciated!

        Happy Holidays!!

        Simon

        YveauxY 1 Reply Last reply
        0
        • X xefil

          Hello @electrik and @Yveaux ; thanks for the answers.
          It's still not totally clear who is retaining those messages.
          It's a mosquitto issue, an issue from the Controller (OpenHAB2 or HomeAssistant) or a driver issue from MySensors?
          BTW, the last case, having updated the MQTT Mysensors gateway as well as the affected sensor leaf, I would discard this last option.
          I need to understand as well how to read the debug messages from mosquitto. It doesn't contain the message value and have no idea if the retain flag is set or not :-) I know that's a little off topic :-)
          Any further help is appreciated!

          Happy Holidays!!

          Simon

          YveauxY Offline
          YveauxY Offline
          Yveaux
          Mod
          wrote on last edited by
          #5

          @xefil said in Strange behavior on MQTT Gateway Reset:

          driver issue from MySensors

          MySensors Sensors, Repeaters and Gateways do not remember or cache any messages.
          If messages are retained somehow, this is certainly not caused by the MySensors network.

          http://yveaux.blogspot.nl

          1 Reply Last reply
          0
          • electrikE Offline
            electrikE Offline
            electrik
            wrote on last edited by
            #6

            it is not an issue, it is a feature in MQTT.
            This retain flag is set by the sender, to allow devices that become online after a device has changed status, obtain the latest status.
            So probably that can be set in openHab or HomeAssistant

            1 Reply Last reply
            0
            • mfalkviddM Offline
              mfalkviddM Offline
              mfalkvidd
              Mod
              wrote on last edited by
              #7

              MySensors does set the retain message on I_BATTERY_LEVEL messages (but no other messages). Such messages are not present in the above debug log, but I thought I'd add a note here for completeness.

              Discussion on extending the retain flag to more message types: https://github.com/mysensors/MySensors/issues/1026

              electrikE 1 Reply Last reply
              0
              • X Offline
                X Offline
                xefil
                wrote on last edited by
                #8

                Ok, thanks all. Maybe it's a flag I've set on HomeAssistant on some variables and to delete them, it's not sufficient, reading the doc, to restart the mosquitto service. I'll look how delete message AND retain flag.
                Thanks all!

                Simon

                1 Reply Last reply
                1
                • mfalkviddM mfalkvidd

                  MySensors does set the retain message on I_BATTERY_LEVEL messages (but no other messages). Such messages are not present in the above debug log, but I thought I'd add a note here for completeness.

                  Discussion on extending the retain flag to more message types: https://github.com/mysensors/MySensors/issues/1026

                  electrikE Offline
                  electrikE Offline
                  electrik
                  wrote on last edited by
                  #9

                  @mfalkvidd said in Strange behavior on MQTT Gateway Reset:

                  MySensors does set the retain message on I_BATTERY_LEVEL messages (but no other messages)

                  If the define MY_MQTT_CLIENT_PUBLISH_RETAIN is used, all messages are retained. But that is not active by default, so probably not used in this case. Just to be complete ;-)

                  X 1 Reply Last reply
                  1
                  • electrikE electrik

                    @mfalkvidd said in Strange behavior on MQTT Gateway Reset:

                    MySensors does set the retain message on I_BATTERY_LEVEL messages (but no other messages)

                    If the define MY_MQTT_CLIENT_PUBLISH_RETAIN is used, all messages are retained. But that is not active by default, so probably not used in this case. Just to be complete ;-)

                    X Offline
                    X Offline
                    xefil
                    wrote on last edited by
                    #10

                    @electrik said in Strange behavior on MQTT Gateway Reset:

                    @mfalkvidd said in Strange behavior on MQTT Gateway Reset:

                    MySensors does set the retain message on I_BATTERY_LEVEL messages (but no other messages)

                    If the define MY_MQTT_CLIENT_PUBLISH_RETAIN is used, all messages are retained. But that is not active by default, so probably not used in this case. Just to be complete ;-)

                    Thanks!
                    Well, I've succesfully deleted the retained messages via cli using mosquitto command:

                    mosquitto_pub -t <my_retained_topic> -r -n

                    Maybe it was set by the controller, then removed, but mqtt was retaining it.

                    Simon

                    1 Reply Last reply
                    1
                    • electrikE Offline
                      electrikE Offline
                      electrik
                      wrote on last edited by
                      #11

                      Great thanks for your feedback!

                      X 1 Reply Last reply
                      0
                      • electrikE electrik

                        Great thanks for your feedback!

                        X Offline
                        X Offline
                        xefil
                        wrote on last edited by
                        #12

                        @electrik said in Strange behavior on MQTT Gateway Reset:

                        Great thanks for your feedback!

                        Thanks to you for the support and hints ;-)

                        I wish you a happy new year!

                        Simon

                        electrikE 1 Reply Last reply
                        0
                        • X xefil

                          @electrik said in Strange behavior on MQTT Gateway Reset:

                          Great thanks for your feedback!

                          Thanks to you for the support and hints ;-)

                          I wish you a happy new year!

                          Simon

                          electrikE Offline
                          electrikE Offline
                          electrik
                          wrote on last edited by
                          #13

                          @xefil thank you, happy new year!

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


                          23

                          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