Match randomly generated clientId to thing-name

0

Hi -
I want to monitor the connections/disconnections of my IoT devices and execute some lambda functions after a connection event happens.
Monitoring the connection state via the lifecycle topics '$aws/events/presence/(dis)connected/#' works perfectly fine but I have a problem identifying the client who sent the disconnect message.
Since the IoT devices use the RESTful API for updating the things shadow, the clientId is randomly generated and not associated to the specific thing.

I looked through the documentations to find a way to match this clientId or any other parameter out of the lifecycle messages to the thing which triggered the message, but I didn't find a way to achieve that.
Is there any way to do that and I'm just missing something or is that just not possible with the current implementation?

  • Mathis

Edited by: mathiswi on Jul 2, 2020 6:14 AM

asked 4 years ago462 views
3 Answers
0

Hi:

AWS IoT Core's life-cycle events (https://docs.aws.amazon.com/iot/latest/developerguide/life-cycle-events.html) are designed to be used for persistent connections using MQTT in order to determine whether a device's connection was established or disconnected. HTTP Rest APIs are using by design short-lived connections and the connection can be multiplexed when using AWS IAM credentials and thereby doesn't provide an indication whether a specific device is "connected".
If you need to tell whether a specific device is connected/online you'll need to use MQTT connections instead. Client IDs are independent of Things and unless the relationship is maintained by the device using a clientID via MQTT that matches its registered Thing name there is no relationship between the two.

AWS
answered 4 years ago
0

As Christoph mentioned, the devices are identified as things if they use thing name as the clientId while connecting to IoT Core. Is there a reason for not able to use thing name as clientId?

We could add thing name in life cycle message but we don't do it today because customers can get thing name from the clientId. Refer https://docs.aws.amazon.com/iot/latest/developerguide/iot-thing-management.html

AWS
answered 4 years ago
0

Hey,

using the thing name as the clientId would definitely be the preferred way but the developer who works on the firmware of the devices was set on using the REST API to push updates to the shadow for some reasons regarding the device architecture.
Apparently it's not possible to manually set the clientId when using the REST API (according to this post https://forums.aws.amazon.com/message.jspa?messageID=751184#751184 ) at this moment which lead to my problem.

I've now brought the reasoning regarding the connectivity using the REST API towards the dev and was able to convince him to change his implementation of the IoT messages to using MQTT so I guess the issue is resolved for now. Thanks for your answers!

Mathis

answered 4 years ago

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