question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to catch exception Websocket Handshake Error while using Cognito Identity

See original GitHub issue

I’m trying to connect to AWS IoT by using Cognito Identity (Authenticated Identity), claim temporary IAM credentials then connect, all operation work as normal until network down. For example, network down for 4 hour and then has internet connection as normal. The problem is temporary credentials cannot refresh while network down (i’m refreshing it inside disconnect callback) and while SDK trying to reconnect when internet connection back, at that time, the IAM credentials has been out dated and it will cause Websocket Handshake Error exception and stuck forever. So I need help to caught exception when above problem happens in order to refresh IAM and reconnect again.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
justinboswellcommented, Oct 3, 2019

Yes, what I’m suggesting is when you receive a disconnect, to start fetching credentials and retry until it succeeds, then update the credentials in the MQTT connection so its next attempt will succeed.

For what it’s worth, this problem is not present in our upcoming v2 version of this SDK, because all of the events are hookable.

0reactions
yehching0109commented, Mar 17, 2022

Hi guys, I am curious about the “on_disconnect” callback func and the renew credentials for websocket handshake issue. May anyone of you can provide the sample code of how you fix this issue? Big thanks,

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing error responses - Amazon Cognito
To sign a user in with ADMIN_USER_PASSWORD_AUTH and USER_PASSWORD_AUTH , include the user name and password in an AdminInitiateAuth or InitiateAuth API request....
Read more >
WebSocket connection failed: Error during ... - Stack Overflow
Problem solved! I just figured out how to solve the issue, but I would still like to know if this is normal behavior...
Read more >
Stomp WebSocket Connection with Server side authorization ...
Client sends request for authorization to Cognito by providing user id/password and gets identity token in return (along with refresh token and ...
Read more >
WebSocket was closed: An exception has occurred while ...
You may need to verify the WebSocket connection on ADS works properly. You can use the rmdstestclient or testclient tool available in the...
Read more >
amazon-cognito-identity-js - npm
Start using amazon-cognito-identity-js in your project by running `npm ... Download the amazon-cognito-identity-js package from npm and get ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found