'AppSync (managed GraphQL) subscription fails sometimes but starts working fine on reloading any page of the application
I went through a lot of documentation including the official documentation of GraphQL and Appsync subscription but was unable to find the cause why subscription fails sometimes.
My current scenario is given below: When the admin updates the permission of a user, the user will automatically get logout and need to login again. In this way, that user will use the application with the updated permissions.
The problem I am facing is given below: Sometimes the user gets logout and sometimes not. The listener always listens on the admin side (from where it is occurring. admin in my case) but does not always listen on the other side (whose permission is updated). Above all, the twist in it is that, on refreshing any page of the application once, the subscription starts working perfectly. I don't know why it starts working fine on refreshing the application.
I implemented a workaround that I am refreshing the page once after login. But this is not a valid solution as it stains the concept of single page application (SPA)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
