frontend react application giving error while calling api gateway if the page is kept idle for some time


i have created a business application using react and cognito for login. My logic are created in lambda functions and are called by the app through api gateway using aws iam authentication by using identity pool. So when i first open my application it gives an error and cannot call lambda function. after reloading it works fine but if the page is kept idle for long and i called a lambda function it gives an error which get resolve on refresh. My question is that does anyone know why this is happening and is there a way to fix it

2 Antworten

Without knowing what type of error is being received (i.e. is it a 401? Is it a 403? Is it a 50x?) or having any logs to review, I'll venture a guess as to what might be causing this: You would get behavior similar to this if your Cognito token expired and was not refreshed. Generally, what you can do to alleviate this is use the refresh token to "refresh" your token when the page is idle. You can find information on how to do that programmatically here. In addition -- make sure your authentication flow is not just checking if the token is present in your browser (in a cookie, for instance) but also that it is not expired -- and if it is expired force your users to re-authenticate.

profile pictureAWS
beantwortet vor einem Jahr

Hi there,

I'd encourage you to retry this operation again. I'm not sure which region, or the full list of services you're using, but want to ensure you're aware of some earlier service impact that could have possibly contributed.

While signed in to your AWS account, please check to see if a service you're using was affected. The increased error rates in our US West (Oregon) region have now been marked as Resolved. If you continue to encounter errors not mentioned on our Health Dashboard status, please do add additional details on this thread.

Thank you!

— Brian D.

profile pictureAWS
beantwortet vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen