aws / aws-iot-device-sdk-js

SDK for connecting to AWS IoT from a device using JavaScript/Node.js
Apache License 2.0
965 stars 385 forks source link

WebSocket connection to 'wss://a85xxxxxxxx.iot.us-west-1.amazonaws.com/mqtt?....' failed #393

Closed harshkoralwala closed 2 years ago

harshkoralwala commented 3 years ago

Hello All,

I am facing some weird issues when the reconnection workflow is executed.

"aws-iot-device-sdk": "^2.2.1",

MQTT connection successfully established with AWS IoT.

When UI is idle it starts to reconnect workflow.

But unfortunately, it didn't get succeed and continuously retry after some time.

I can not find any reason for such behavior from error.

When I searched for a similar issue I can see for others it shows errors like handshake failure etc.

image psd

My connection configuration looks like(Angular 6):

var awsIot = require('aws-iot-device-sdk'); this.iotDevice = new awsIot.device({ host: <Endpoint>, clientId: <clientId>, accessKeyId:<accessKeyId>, secretKey: <secretAccessKey>, sessionToken: <sessionToken>, protocol: 'wss', baseReconnectTimeMs: 1000, debug: false });

Thanks in advance.

jmklix commented 3 years ago

You should try using the ats endpoint: <prefix>-ats.iot.<region>.amazonaws.com

harshkoralwala commented 3 years ago

@jmklix Thank you for your reply.

My whole Endpoint looks like this: a85xxxxxxxxxxx-ats.iot.us-west-1.amazonaws.com

So it looks like the URL schema is already matching as per your suggestion.

Any other suggestions?

jmklix commented 3 years ago

Can you include more details about how you have your setup? and which example you are trying to run.

I experience no websocket connections issues when running the mqtt-explorer example without angular 6

heyralfs commented 2 years ago

Any updates? same problem here

harshkoralwala commented 2 years ago

@jmklix @heyralfs

The issue was with local storage. My application was clearing all local storage data on some activity. So it looks like for the re-connect scenario, the module needs some stored data from local storage. After not removing local storage data, the Same issue was not found.

Hope this helps

jmklix commented 2 years ago

@harshkoralwala glad you where able to fix your problem!

@heyralfs hopefully your problem was solved, but if it wasn't please open a new ticket detailing your specific problem.

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

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.