Amplify-js: Appsync graphQL connection closed error

Created on 27 Oct 2020  Â·  25Comments  Â·  Source: aws-amplify/amplify-js

Hi I am using subscription via graphQL and getting frequent connection closed error from Appsync, for no apparent reason. It seems to happen at random times. Don't know how to reproduce it.

Screen Shot 2020-10-27 at 6 23 09 PM

My .js code:

subscribeExhibitorNotifications = async() => {
try {
this.exhitorStatusSubscription = await API.graphql(graphqlOperation(onCreateOveceventsExhibitorStatus));
if (this.exhitorStatusSubscription) {
this.exhitorStatusSubscription.subscribe({
next: (event) => { ...
}
else {
....
}
},
error: error => {
console.log("error in graphQL onCreateOveceventsExhibitorStatus: ", error);
}
});
}
}
catch (e) {
console.log("error in graphQL onCreateOveceventsExhibitorStatus: ", e)
}
}

Schema:

export const onCreateOveceventsExhibitorStatus = /* GraphQL */ subscription OnCreateOveceventsExhibitorStatus { onCreateOveceventsExhibitorStatus { id datetime status } } ;

export const createOveceventsExhibitorStatus = /* GraphQL */ mutation CreateOveceventsExhibitorStatus($id: String!, $status: String!) { createOveceventsExhibitorStatus(id: $id, status: $status) { id datetime status } } ;

API to-be-reproduced

Most helpful comment

Hello amplify guys, any luck?

All 25 comments

for more info, i also see a comment from webpack after the appsync error:

image

Not sure if it's react closing the connection or appsync causing react to print out that command.

that's my version of react:

"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.3"

Same here. I have a react app with three subscriptions and all subscriptions received a "Connection Closed" in a complete random way.

Sometimes the connections are stable and sometimes they are closed after a couple minutes.
I will continue to investigate.

Hello amplify guys, any luck?

Hi, I’m from the AppSync team. I’m happy to look into the issue you’ve been seeing, would anyone impacted be able to share a rough timestamp (open time and drop time), api id, and region for a connection that dropped? Sorry for the issues!

Hi Chunyanj is it possible to send you a private message regards to API id?
In the meanwhile the other info:

region is us-east-1
open time probably around 10am EST (not quite sure if i am remembering the open time accurately), drop time around 1:35pm EST, all 29th oct 2020.

Thank you for the response! We have started to investigate. The API id has been recorded and you could delete the comment if you want. We will get back to you when we have update.

great - thank you.

hi Chunyan

I have another question and i have been seeing those questions over the web but no response - if a device is online and currently get subscriptions, then goes offline and then online again, will the subscription still work and then get the latest mutation that was missed?

hi there -> any upates? thanks!

Hey mchitson, we are actively investigating the ticket. Sorry for any inconvenience. Please expect an update today.

As for the question above, unfortunately the answer is no. Typically, people could achieve this using delta sync. The doc for delta sync is here: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-delta-sync.html

thanks but the document is not very detailed. it's unclear to me whether i need to use datastore with it or what datasync client to use. datastore also does not seem to recover subscriptions - at least not the way i see it documented.

Hey mchitson, we have root caused it.

Sorry for the issue. We dove deep to confirm, and this is an issue we’ve seen reported a few times where code deployments on our end can result in connections temporarily being broken up. We’re investigating a few avenues to alleviate some of these headaches, both on the client end and on our end. Thanks!

Thanks for you feedback of the doc, we'll put this in our backlog and discuss improving it!

Thank you Chunyan

So going forward there shouldn’t be a connection closed issue?

On Nov 3, 2020, at 8:24 PM, chunyanj notifications@github.com wrote:


Hey mchitson, we have root caused it.

Sorry for the issue. We dove deep to confirm, and this is an issue we’ve seen reported a few times where code deployments on our end can result in connections temporarily being broken up. We’re investigating a few avenues to alleviate some of these headaches, both on the client end and on our end. Thanks!

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Also I am trying Datastore as I would like my subscriptions to be up to date when a device is temporarily disconnected and reconnected. I am however getting those errors:
DataStore - subscriptionError Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined:

My package.json:

"dependencies": {
"@aws-amplify/cli": "^4.32.0",
"@aws-amplify/datastore": "^2.7.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"aws-amplify": "^3.3.7",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},

Secondly, am also seeing a timeout disconnect on appSync at less than 5mins. Is there a way to re-subscribe with appsync after this?

On Nov 3, 2020, at 8:24 PM, chunyanj notifications@github.com wrote:

Hey mchitson, we have root caused it.

Sorry for the issue. We dove deep to confirm, and this is an issue we’ve seen reported a few times where code deployments on our end can result in connections temporarily being broken up. We’re investigating a few avenues to alleviate some of these headaches, both on the client end and on our end. Thanks!

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/aws-amplify/amplify-js/issues/7070#issuecomment-721460458, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALSSPFRR6K7C2TBXDVKGYNLSOCUNZANCNFSM4TBP7NZA.

Hello Chunyan

The connection closed yet again last night around: 10:41 pm EST. I couldn't quite figure out from your response whether that problem has been solved or is still being solved after the root cause was identified. Thanks!

Hello

I have yet another connection close at 5:15Pm 11/4/2020, i am going live soon and this can not happen so frequently, is this being fixed now that you have identified the root cause?

Hey mchitson,

Sorry for the ambiguity we made! The issue hasn't been solved 100% but we have taken actions to reduce the possibility of happening. We believe we can keep the frequency of happening in a very low rate.

As for the re-subscribe question, we'll provide an update later.

Thanks for the feedbacks!

Hey Chunyan

Am not sure if it’s as a result of what you guys have done to improve things, but I am getting disconnected even more often now! Like literally 20 mins ago!

On Nov 4, 2020, at 8:06 PM, chunyanj notifications@github.com wrote:

Hey mchitson,

Sorry for the ambiguity we made! The issue hasn't been solved 100% but we have taken actions to reduce the possibility of happening. We believe we can keep the frequency of happening in a very low rate.

As for the re-subscribe question, we'll provide an update later.

Thanks for the feedbacks!

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/aws-amplify/amplify-js/issues/7070#issuecomment-722060548, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALSSPFXGHTBLY2QKPFOGT23SOH275ANCNFSM4TBP7NZA.

i am still getting that connection closed issue happened yesterday again, barely couple of hours after my app started.

11/9/2020 10:19:12 PM Objecterror: errors: Array(1)0: {message: "Connection closed"}length: 1__proto__: Array(0)__proto__: Objectprovider: AWSAppSyncRealTimeProvider {_config: {…}, socketStatus: 0, keepAliveTimeout: 300000, subscriptionObserverMap: Map(0), promiseArray: Array(0), …}__proto__: Object
GraphQLServices.js:79

Hey mchitson,

Thanks for the feedback! We'll investigate it again to see if it is the same root cause.

I also faced connection closed issue today.

{
"provider": {

"socketStatus": 0,
"keepAliveTimeout": 300000,
"subscriptionObserverMap": {},
"promiseArray": [],
"awsRealTimeSocket": null,
"keepAliveTimeoutId": 202

},
"error": {
"errors": [
{
"message": "Connection closed"
}
]
}
}

Good afternoon, this uncaugth exception was raised in console for my web apps.
This exception can reflect an security breach for all api environment that it working with graphql...

Steps:

  1. activate airplane mode
  2. desactivate airplane mode
  3. move to other tabs in browser
  4. go the tabs with the web app and this error show for me in the console

image

Was this page helpful?
0 / 5 - 0 ratings