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.