0

We're considering AWS IoT for an upcoming project featuring devices with unreliable network connections. One requirement is to send commands to devices. The commands must be reliably delivered (ack'd) and the devices should also signal success/failure when the commands are completed later. It seems that just publishing commands to an MQTT topic won't ensure the message gets delivered, given that AWS don't support persistent sessions - is this right?

We've been speculating about poking the command into an array of commands inside the device shadow's 'desired' state. The device could then ack receipt of the command by replicating the command in the shadow's 'reported' state, and report success/failure by setting an outcome field within the command in the 'reported' state.

Given our lack of experience with AWS IoT, does this seem like a sane approach? Or can anyone see anything neater? One nasty thing about this is that the shadow accumulates completed commands, which presumably means that I will eventually need some kind of housekeeping to remove the completed commands to keep the shadow to a reasonable size.

Finally, does anyone know how clever the bandwidth use is - if my server adds an element to an array of one hundred elements nested deeply inside the 'desired' state, how much data actually flows over the wire? And similarly when my device moves the element into the 'reported' state.

  • It is a good design practise to consider all network connection as "unreliable". In the IoT space for sure all connections to devices must be considered "unreliable". – Stefan Vaillant Sep 15 '16 at 06:05
  • yes. It's a huge shame that Amazon haven't implemented MQTT fully: it was designed well and leaving bits out seems a bit feeble. – David Cleal Sep 29 '16 at 10:21

1 Answers1

0

You are right that AWS IoT doesn't support persistence session nor message retention.

As for using shadow device to store the command queues, it really depends on the frequency and variety of commands you have. What I can think of:

  • If it's only used infrequently (e.g. once a month) then probably using shadow device is fine from management and performance perspective. However if it's few commands every few minutes then it becomes huge quickly.

  • If there's only few types of commands (with no parameters) and each will only needed to be executed once at a time, then the command could be the key while "true" / "false" is the value. The desired can set "true" to indicate that device should execute it, then once the device has completed the job, it reports "false".

Hope this helps you.

Calvin Boey
  • 331
  • 3
  • 6
  • Thanks for the reply. I think we pretty much decided not to use IoT: running our own MQTT might be better, persistent sessions is probably a harder problem than any of the ones that IoT actually solves. – David Cleal Sep 29 '16 at 10:20
  • AWS IoT Core now supports persistent sessions: https://docs.aws.amazon.com/iot/latest/developerguide/mqtt-persistent-sessions.html – Sinan Erdem Apr 08 '20 at 19:04