Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get AWS IOT client id?

I use AWS IoT for real-time update in my web application. The application connects to AWS IoT using aws-iot-device-sdk:

const client = awsIot.device({
    region: awsConfig.region,
    protocol: 'wss',
    accessKeyId: <accessKey>,
    secretKey: <secretKey>,
    sessionToken: <sessionToken>,
    port: 443,
    host: <iotEndpoint>
});

client.on('connect', res => {
    // ok
});

I want to use AWS Lifecycle Events. For example:

$aws/events/presence/connected/{clientId}

How to get MQTT client id?

like image 882
Ildar Avatar asked Oct 08 '17 17:10

Ildar


People also ask

How do I find my AWS client ID?

Privacy Notice URL: Url of the page where you have mentioned the privacy policy page of your store. Logo Image: Select optional logo image of your store. After filling these details, click on the Save button. Step 5: Now click on Web Settings to get your client id and client secret.

What is client ID in AWS IoT core?

MQTT client IDs uniquely identify MQTT connections. If a new connection is established using a client ID that is already claimed for another connection, the AWS IoT message broker drops the old connection to allow the new connection. Client IDs must be unique within each AWS account and each AWS Region.

How do I get my AWS IoT endpoint?

The AWS IoT device service endpoints support device-centric access to security and management services. To learn your account's device data endpoint, you can find it in the Settings page of your AWS IoT Core console.

Is AWS IoT a MQTT broker?

The AWS IoT Core MQTT broker and AWS IoT Device SDK are also compliant with the MQTT 3.1. 1 standard, so you can use these features to create an application that uses MQTT 3.1. 1 across your devices and the AWS Cloud. Choose this option to use MQTT 5 features in communication between core devices and client devices.


2 Answers

Whenever you define a thing in AWS IoT, a unique identifier will be assigned to your device in your AWS IoT account. By default it is same as the name of thing(defaultClientId) and you can use it for connect to the AWS IoT broker. You can retrieve informaiotn about your thing by using AWS SDKs(or name of your device). For example by using Python SDK:

import boto3
client = boto3.client('iot')
response = client.describe_thing(
    thingName = [Name of your thing in AWS IoT]
)

print(response)
like image 162
Keivan Avatar answered Sep 18 '22 13:09

Keivan


If you look at the documentation, you will see that clientId is one of the parameters you can supply to the device() method. You should be generating a client ID for each connected device that is unique to your application (i.e. unique to your AWS IoT account).

like image 20
Mark B Avatar answered Sep 21 '22 13:09

Mark B