Closed harshkoralwala closed 3 years ago
My knee-jerk response to the described behavior here is that this is likely an mqtt-js issue as opposed to the iot sdk (but that could be wrong). In the time since you opened this, we've performed a major update to the runtime dependencies (mqtt 2.x -> mqtt 4.2.8) which would include a ton of bug fixes to the low level client. Can you regress against the latest version of the SDK (2.2.10)?
Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.
Hello,
I have developed Web application using aws-iot-device-sdk-js "^2.2.1",+ Nodejs+Angular+AWS.
When I run the application locally on chrome or firefox, on the refresh page, The offline and close event not called, and after page refresh, the MQTT connection established as expected.
I have deployed the same working code on AWS s3 with a static website, and while accessing the s3 link with Mozilla firefox. After login when the MQTT connection established and if I refresh the page, the offline and close events are called.
As an error handling in the close event, the logout code is there as without MQTT, the app can not be used.
As a result on every refresh after login of Mozilla, the user logged out.
I can not reproduce the same scenario on Mozilla/chrome with localhost and with s3 link +chrome.
Kindly refer to the below code:
this.iotDevice = new awsIot.device({ clientId: Math.round((Math.random() * 36 ** 12)).toString(36), accessKeyId: AWS.config.credentials.accessKeyId, secretKey: AWS.config.credentials.secretAccessKey, sessionToken: AWS.config.credentials.sessionToken, protocol: 'wss', host: host URL here, }); const self = this; this.iotDevice.on('connect', function () { console.log('AWS IoT Device connected'); }).on('error', (error) => { console.log('AWS IoT Device error', error); }).on('offline', function (offlineData) { console.log('AWS IoT Device offline', offlineData); }).on('close', function (data) { console.log('AWS IoT Device close', data); //logout code here }).on('message', function (topic: string, payload: any) { //do something here });
Kindly help me with this.