AWS IOT core sample: assignedclientIdentifier

0

Hello

In the sample code for customer auth IOT core - https://github.com/aws/aws-iot-device-sdk-js-v2/blob/main/samples/browser/custom_authorizer_connect/

we would like to have AWS IOT core SDK generate a client identifier (in MQTT terminology assignedClientIdentifier) without app passing a random id to it (as given in the sample).

  1. if we use the above sample (without passing client id from app), does aws IOT JS SDK or IOT core server generate a client Id if connection is successful? we find that value is empty though connect went through
  2. If the change the above sample code to use IOT core MQTT 5 data structure and APIs, after connection is successful, we see that the assignedClientIdentifier is not empty - .. "assignedClientIdentifier":"$GEN/1e02002e-25d3-4266-aa75-80c931cf6fbe" so if we want to persist the same connection, how can I pass the same identifier during re-connection. we didn't find any API to send the same identifier in IOT core SDK mqtt5 client during re-connection (basically something similar to .with_client_id in mqtt31 API , not there in mqtt5 API). any ideas?

Thanks Suresh

Suresh
已提問 2 個月前檢視次數 114 次
1 個回答
1
已接受的答案

In researching further, this appears to be a differentiation between the MQTT 5 specification and how AWS IoT Core has implemented it. This GitHub issue appears to describe what you are seeing.

As noted by the requester, there is a workaround that may work for you too:

import { v4 as uuidv4 } from 'uuid';

// ...
builder.withConnectProperties({ keepAliveIntervalSeconds: 120, clientId: uuidv4() });
// ...

Please let me know if this resolves your issue. In the meantime I'll ensure the AWS IoT Core team knows about this, either to adhere to the specification or document the difference for others.

AWS
Gavin_A
已回答 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南