aws-mobile-appsync-sdk-js icon indicating copy to clipboard operation
aws-mobile-appsync-sdk-js copied to clipboard

Managing Reconnection Attempts for AWS AppSync Subscription with Apollo

Open objectiveSee opened this issue 1 year ago • 2 comments

I'm working on a project using AWS AppSync with Apollo to manage GraphQL subscriptions. I'm using aws-appsync-subscription-link with an Apollo subscription for real-time data. Everything works fine until the subscription connection is lost. Then, I have trouble getting the connection back automatically.

My main question is how to set up aws-appsync-subscription-link or Apollo so that if a subscription connection is lost or has an error, it tries to reconnect automatically. I've looked through a lot of documentation and forums but haven't found a clear answer or example on how to handle automatic reconnection in these situations.

I'd appreciate any advice or examples on how to adjust the configuration to retry the connection if it fails. Tips on the best ways to handle reconnection with AWS AppSync and Apollo would be really helpful. Thanks!

For more background, you can check out an issue I opened in the Apollo repository. They sent me here to find a solution to my problem.

Issue Link

Are you requesting a feature or reporting a bug? 🐛 bug

What's happening now? When a subscription connection is lost, the system doesn't try to reconnect automatically.

If this is a bug, can you tell me how to reproduce it and, if possible, show a simple example of the problem?

  • Set up a subscription connection using aws-appsync-subscription-link with Apollo.
  • Lose the connection somehow, like by turning off the internet. You can also just have Wifi off from the beginning (eg. never connected)
  • Notice that it doesn't try reconnect after it has an error in connecting.

What should happen?

  • When a subscription connection is lost, it should try to reconnect automatically.

Which versions and environments (browser, react-native, nodejs) / OS are affected? Did it work in earlier versions?

Environment: React OS: Mac

Related Issues

  • https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/740#issuecomment-1473770416
  • https://github.com/awslabs/aws-mobile-appsync-sdk-js/issues/684#issuecomment-1774770537
  • Possible solution??! Does this work for React Native?: https://github.com/awslabs/aws-mobile-appsync-sdk-js/pull/606

objectiveSee avatar Oct 21 '23 01:10 objectiveSee

+1 on this issue

mengdi avatar May 28 '24 20:05 mengdi

+1

samsuchin avatar Jun 05 '24 22:06 samsuchin