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

질문됨 4년 전467회 조회
3개 답변
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
답변함 4년 전
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
답변함 4년 전
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

답변함 4년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠