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

Unhandled GraphQL subscription error - AMQJS0008I Socket closed.

Open markb321b opened this issue 6 years ago • 3 comments

Note: If your issue/feature-request/question is regarding the AWS AppSync service, please log it in the official AWS AppSync forum

See also the following (which is the same issue, but may have replies I suppose) https://forums.aws.amazon.com/thread.jspa?threadID=311194&tstart=0

Do you want to request a feature or report a bug?

BUG

What is the current behavior?

Appsync for mobile, where network is inherently unreliable, has the following easy to reproduce problem.

1./ Create a React App to work with AppSync where you want to use GraphQL subscriptions (I've been through many examples, here's the latest https://tylermcginnis.com/building-serverless-react-graphql-apps-with-aws-appsync/)

2./ Build and run the App and all works fine.

3./ Take the client browser off line for about 60 seconds, and then take it back online.

Result. Very consistently, you get the following issue logged/highlighted to the developer tools console :

  • Unhandled GraphQL subscription error
  • errorMessage: "AMQJS0008I Socket closed." The behaviour is totally reproducible using many of the AppSync or Amplify example projects in the AWS git samples code repo (Note: I'm focusing on the ones that illustrate subscriptions).

As far as I can tell, the bit of code that croaks is node_modules/apollo-client/core/ObservableQuery.js (you can search for "Unhandled GraphQL subscription error" in that file. Sometimes the stack trace in the console window will have highlighted it.)

As far as I can tell, the AppSync node package is pegged to a version Apollo Client that will always give this behaviour, and there seems to be no way to break that dependency and get past this behaviour (after a lot of research that's what I've concluded, and I hope to be proved wrong by some helpful person latter in this thread.) I've also had this self same issue with this example project https://github.com/awslabs/aws-mobile-appsync-sdk-js/tree/master/tutorials/react-offline-realtime-todos.

So if you want to know what the package.json looks like to reproduce this problem - look in the two example "demo" project repos I've supplied.

In the end, after weeks of learning curve, this is a show stopper for me. Would love to know how to get around this.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

See text above.

What is the expected behavior?

See text above. I expect the thing to be robust to intermittent network for mobile devices.

Which versions and which environment (browser, react-native, nodejs) / OS are affected by this issue? Did this work in previous versions?

React - using a browser on mobile (but you get the same behaviour on desktop).

markb321b avatar Oct 12 '19 15:10 markb321b

Facing the same issues. Subscriptions don't recover from network outages. Is this a bug or intended behaviour? Is anyone replying to those issues?

ankanlim avatar Jan 30 '20 20:01 ankanlim

@ankanlim sorry for the late response, we are looking into this

elorzafe avatar Apr 15 '20 20:04 elorzafe

Experiencing the same. At least I'm able to resubscribe on error.

Dein1 avatar Jun 24 '22 14:06 Dein1