[SOLVED] Strange behavior on MQTT Gateway Reset



  • 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



  • @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/


  • Mod

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



  • 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


  • Mod

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



  • 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


  • Mod

    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



  • 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



  • @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 😉



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



  • Great thanks for your feedback!



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



  • @xefil thank you, happy new year!


 

375
Online

8.1k
Users

8.9k
Topics

95.3k
Posts