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달 전

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

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

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