Closed chunhuajiang closed 6 years ago
Hi @tidyjiang8,
The AWS IoT broker does support last will and testament.
However, I noticed that you are trying to publish your LWT to $aws/things/HUB_2479d22b3f654d8ea33d4fbbd33610df/shadow/update
. Please see the documentation here.
Currently, LWT messages sent to AWS IoT reserved topics (topics that begin with $) are ignored by the AWS IoT Device Shadow service, but are still processed by subscribed clients and by the AWS IoT rules engine. If you want the Device Shadow service to receive LWT messages, register an LWT message to a non-reserved topic and create a rule that republishes the message on the reserved topic.
Got it, thanks!
Hi @gordonwang0, The problem was resolved, but I'm curious about why it is designed to do so, could you explain the reason if it's possible?
Hi @tidyjiang8,
I can't give the exact reason publicly. But it has to do with how our internal systems were designed, and that we haven't seen a compelling case to change it.
ok, thanks @gordonwang0
Hi @tidyjiang8,
The AWS IoT broker does support last will and testament.
However, I noticed that you are trying to publish your LWT to
$aws/things/HUB_2479d22b3f654d8ea33d4fbbd33610df/shadow/update
. Please see the documentation here.Currently, LWT messages sent to AWS IoT reserved topics (topics that begin with $) are ignored by the AWS IoT Device Shadow service, but are still processed by subscribed clients and by the AWS IoT rules engine. If you want the Device Shadow service to receive LWT messages, register an LWT message to a non-reserved topic and create a rule that republishes the message on the reserved topic.
Hi @gordonwang0, I am in the same situation (I wish to monitor the connection status of my device), I read the documentation. In other to goes around the limitation, we need to create a rule in Rule engine to re-post the topic back to device shadow.
But what if I want to do this on >1000 device (each device have different 'thingName')? Is not practical to create 1000 rules. In this scenario, how to write 1 rule to handle multiple devices?
Hi @dennislwy,
You can use wildcards your rule. Something like
{
"rule": {
"ruleDisabled": false,
"sql": "SELECT * FROM 'my/things/+/update'",
"description": "Turn my/things/ into $aws/things/",
"actions": [{
"republish": {
"topic": "$$aws/things/${topic(3)}/shadow/update",
"roleArn": "arn:aws:iam::123456789012:role/aws_iot_republish"
}
}]
}
}
(where the +
wildcard and topic(3)
stand for Thing Name)
Hi @gordonwang0, I tried using rule engine to republish last will and update shadow. It worked. But there's one problem. If an inactive client disconnects after connecting to AWS IoT broker for a while, its last will will not be sent immediately. Instead, it will be sent after a long delay(roughly 3 min delay).
I'm guessing this has something to do with how AWS IoT broker works internally.
@yles9056 I think your mqtt keep alive time determines the delay.
I have a situation that has 1) my device online and working. 2) connection breaks 3) keep_alive timer is running 4) device comes back online before keep_alive timer expires 5) Even while connected I get LWT message.
Is there a way to cancel the LWT message if I come back online before keep_alive timer expires?
Hi, I want to use the feature of will message, but it does not work as my expected. My steps:
I checked the MQTT control packet CONNECT & CONNACK at device side, all fields are correct, so I'm doubt whether your broker supports will message.
Attach the control packet:
and my analysis of CONNECT packet:
Regards & Thanks