I'm working on a web application where the user can login with AWS Cognito. After login with the AWS credentials I'm connecting to AWS IoT device like
var device = AwsIot.device({
clientId: clientID,
host: host,
accessKeyId: credentials.accessKeyId,
secretKey: credentials.secretAccessKey,
protocol: 'wss',
sessionToken: credentials.sessionToken,
offlineQueueing: 'false'
});
Then once the user logout from the app using AWS Cognito using
cognitoUser.signOut();
Then after logout I want to disconnect the the AWS IoT device as well. Right now I'm seeing even after the logout the device is listening to the events like
device.on('close', function() {})
device.on('error', function() {})
device.on('offline', function() {})
Can someone please specify which function should I call to disconnect the device as well so that it don't listen to these events as well.
I was going through the doc https://github.com/aws/aws-iot-device-sdk-js But I didn't got any specific function for this.
Moreover I used the AWS credential to connect the AWS IoT device, and once I logout from Cognito then the device should have been automatically disconnected as well I think. Please let me know what should be the approach here.
Check device connection status using the console To check the connection status using the console, navigate to the Devices page of the AWS IoT console and choose the device you've added. In the Details section of the Wireless devices details page, you'll see the date and time the last uplink was received.
Finally, AWS IoT Core accelerates IoT application development. It serves as an easy to use interface for applications running in the cloud and on mobile devices to access data sent from connected devices, and send data and commands back to the devices.
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.
The communication of IoT devices can be unidirectional (send data) or bidirectional (send and receive data). If it is a remote communication then the data has to be transferred via a gateway. The network protocol used can be Wi-Fi, Bluetooth, Satellite, or directly connecting to the internet via ethernet port.
I got the answer from AWS IOT support team on this.
The
AwsIot.device
class is a wrapper for the MQTT class with helpers to assist with connecting to AWS endpoints To disconnect your device, you can calldevice.end();
This will close your connection and invokedevice.on('close')
. As for Cognito Sign-out. This will not invalidate the session credentials already provided by Cognito which were used to establish the connection. They will continue to be valid until their assume role time expires.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With