Greengrass client devices last will (LWT) messages not firing

0

We are using the Moquette broker (version 2.3.3) connecting a client device with the python SDK (awsiotsdk==1.11.8) via the following:

lwt = mqtt.Will(
                topic=self._greengrass_lifecycle_topic,
                qos=mqtt.QoS.AT_MOST_ONCE,
                payload=json.dumps({
                    'eventType': 'disconnected',
                    'clientId': self._iot_device._config.thing_name
                }).encode('utf-8'),
                retain=False
            )

mqtt_connection = mqtt_connection_builder.mtls_from_path(
                    endpoint=endpoint,
                    port=port,
                    cert_filepath=self._iot_device._device_cert_path,
                    pri_key_filepath=self._iot_device._device_key_path,
                    client_bootstrap=client_bootstrap,
                    ca_filepath=root_ca_path,
                    client_id=self._iot_device._config.thing_name,
                    clean_session=False,
                    keep_alive_secs=6,
                    will=lwt,
                    on_connection_interrupted=self.on_connection_interrupted,
                    on_connection_resumed=self.on_connection_resumed)
                connected_future = mqtt_connection.connect()

Client connect and graceful disconnect (power down, kill process) works as-expected, but when we pull the Ethernet cord of our IoT thing the LWT message never fires.

I have tried using QoS=2 but it still doesn't fire. The documentation seems to say that all of this should be supported (https://docs.aws.amazon.com/greengrass/v2/developerguide/mqtt-broker-moquette-component.html)

Any idea why this isn't working?

asked 9 months ago208 views
3 Answers
0
Accepted Answer

After updating to the latest Nucleus and client libraries we are no longer seeing this issue. Closing.

answered 8 months ago
0

Hi. Are you trying to get the LWT received at AWS IoT Core? Or just by other clients connected to the Moquette broker?

If the former, then you need to have setup the MQTT Bridge config for the LWT topic, as you perhaps already know.

profile pictureAWS
EXPERT
Greg_B
answered 9 months ago
  • What do you mean that nothing fires? If LWT is being sent upon disconnect, then that's working properly.

  • @MichaelDombrowski-AWS sorry, my comment above was unclear. LWT is being sent on disconnect if I kill the process. LWT is not being sent on timeout-based disconnect, i.e. I pull the Ethernet cord. This is 100% reproducible.

  • Correct, we have the bridge setup to forward to IoT Core. We know this is working correctly, as we get successful disconnect messages on graceful disconnect. It's only when the client disconnects via timeout (pulling the Eth cable) that nothing fires.

  • I'd recommend that you use the EMQX broker in this case. Moquette should be working, but it is certainly possible that something is going wrong there.

  • Switching brokers is not really trivial for us due to the nature of the products we build. Can AWS confirm this functionality exists in the EMQX broker? Can AWS confirm this is an existing bug w/ the Moquette component? Perhaps there's an upstream fix there?

0

How long are you waiting for LWT message? Do you have other keep-alive settings, etc, set? I just performed a an experiement where I blocked port 8883 from a client and LWT was sent sometime after

AWS
answered 8 months ago
  • We have waited upwards of 10 minutes after disconnecting the client's Ethernet cable. The only keep alive setting that we're actively setting is keep_alive_secs=6. Are you testing with any other non-default settings? Can you try disconnecting the client's network connection instead of blocking the port server-side? Not sure if that will result in different behavior.

  • Used same connection settings, but with a 30 second keep alive. Would you mind sharing snippet of code for your client that's subscribed to the will topic?

  • Just re-read everything, didn't realize bridge was in between. So just to clarify, you have client --> bridge --> iot core. And for will message are you subscribed to iot core or bridge?

  • Correct: client -> bridge -> core. We know everything is configured correctly since we get the LWT message (via IoT Core) on graceful disconnect. It's really only when we pull the Eth cord that it doesn't fire.

    All of our client code is posted above in the main question. Were you looking for something else in particular?

    Thank you!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions