Copyright ©

Mongoose OS Forum



Hi there
Greetings from Bangkok!
I'm in a bit of a struggle with my MQTT LWT. If set to the following, AWS simply closes the connection:
["mqtt.will_message", "{\"state\": { \"reported\" : { \"online\" : 0 } } }"]
If I omit the qotes things are working fine:
["mqtt.will_message", "{state: { reported : { online : 0 } } }"]
Obviously this cannot be the solution as it isn't valid JSON anymore.
Is the escape sequence for " wrong? Or do I miss anything else?
Thanks for your help!


  • SergeySergey Dublin, Ireland
    edited February 7

    Just use single quotes in yaml:

      ["mqtt.will_message", '{"foo":1}'],

    Or, you can always change the config dynamically:

    mos config-set mqtt.will_message='{"a":1}'

    Could you share what project you're working on, please?

  • thanks, Sergey!
    with single quotes it works perfectly fine.

  • hmm, while the problem of slammed connections is gone, it's still behaving strangely (or more likely, I'm still trying to do something stupid :-) )

    in conf_schema.yaml:

    ["mqtt.will_message", '{"state":{"reported":{"online":0}}}'],

    after boot:

    >mos config-get mqtt.will_message


    so far so good, let's kill the device..

    Message as received by AWS:



    back on the console:

    mos config-set mqtt.will_message='{"state":{"reported":{"online":0}}}'

    mos config-get mqtt.will_message


    no more double-quotes?

    Message as received by AWS:

    Any ideas?

  • I'm still stuck. Has anyone of you managed to configure a valid JSON MQTT "last will and testament" message? Would appreciate your help :-)

  • SergeySergey Dublin, Ireland

    Looks like a config parsing bug on our side - no unescape is done.
    Bear with us, will come back with the fix shortly.

  • SergeySergey Dublin, Ireland

    Update your firmware, should work now.
    Let me know how it goes please

  • Thanks, Sergey
    The LWT looks fine now.

Sign In or Register to comment.