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
preguntada hace 2 meses114 visualizaciones
1 Respuesta
1
Respuesta aceptada

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
respondido hace 2 meses

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas