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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ