amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Subscription events are no longer being received

Open cjsedwards opened this issue 6 years ago • 28 comments

Describe the bug I have a subscription defined in amplify graphql, and being subscribed in Vue. The subscription events were being received, but recently stopped working.

Amplify CLI Version 4.21.3

To Reproduce Here is part of the definition:

type Mutation {
  addMessage(channelID: ID!, content: String!): ID @function(name: "orchestraBackend-${env}") @auth(rules: [{allow: private, provider: userPools}])
}

type Subscription {
  onNewMessage(channelID: ID!): ID @aws_subscribe(mutations: ["addMessage"])
}

cjsedwards avatar Jun 17 '20 23:06 cjsedwards

I'm seeing the same issue on multiple (AppSync) projects, all managed by Amplify. One of them is in active development but I'm also seeing failed subscriptions on older projects that haven't been touched in months.

cjmartin avatar Jun 17 '20 23:06 cjmartin

A few questions here

  • Are you seeing any errors when you try to run the subscription?
  • Are you using Amplify Lib or are you running these subscriptions from the console?

There is another issue on subscriptions not triggering we are tracking. We'd like to dive into this more and see they might be related. https://github.com/aws-amplify/amplify-cli/issues/4462

SwaySway avatar Jun 18 '20 01:06 SwaySway

Hi @SwaySway , thanks for looking into this.

I'm using the Amplify libraries. I get back a subscription objection successfully with no errors.

cjsedwards avatar Jun 18 '20 14:06 cjsedwards

I talked with the service team and there was a temporary issue with subscriptions that is resolved by now, please retry and if the issue persist get back to us, however the issue is not CLI related but we can help by asking the team in these situations. Another forum could be to ask in our community on discord at: https://discord.gg/amplify

attilah avatar Jun 18 '20 22:06 attilah

@attilah Can you tell me more about the cause of the issue? The subscription issue has not resolved on my end. Some of my subscriptions are working, but the one I specified in this issue is not.

cjsedwards avatar Jun 19 '20 12:06 cjsedwards

@brene This issue is still happening, can we reopen this please?

cjsedwards avatar Jun 19 '20 13:06 cjsedwards

Cc @attilah @UnleashedMind

renebrandel avatar Jun 19 '20 16:06 renebrandel

Hi @cjsedwards - I've been chatting with the AppSync PM. They were aware of an issue and it was fixed on June 18 at 8:50 UTC+2. Can you create a support ticket for the AWS AppSync team? That way they can pursue this issue further.

renebrandel avatar Jun 19 '20 17:06 renebrandel

@brene Where do I do that? I don't see an AppSync github repo or a way to submit issues to them.

cjsedwards avatar Jun 19 '20 17:06 cjsedwards

You can do so in the AWS console. Let me know if you have any other questions around this. image

renebrandel avatar Jun 19 '20 17:06 renebrandel

@cjsedwards when the subscription is triggered, can you see the start and start_ack message in websocket? You can find this in Network tab of Developer tools Screen Shot 2020-07-02 at 2 14 20 PM

yuth avatar Jul 02 '20 21:07 yuth

Ok yes I am seeing this, I sent a message as well test test it out, and I didn't receive anything after the start_ack. image

cjsedwards avatar Jul 02 '20 21:07 cjsedwards

And I can confirm that I did send a message with the same channelID, here is the request I sent: image

cjsedwards avatar Jul 02 '20 21:07 cjsedwards

@cjsedwards would it be possible to share your schema. The part I am specifically interested in is the graphql transformers output schema (which is located in <project-root>/amplify/backend/api/<api-name>/build/scheam.graphql) the subscription type. I am wondering if the onNewMessage subscription has @aws_subscribe(mutation:["addMutation"])

yuth avatar Jul 02 '20 22:07 yuth

@yuth image

cjsedwards avatar Jul 02 '20 22:07 cjsedwards

I see the subscription is wired correctly, and websocket connection for subscription is open and subscription has started. I am not sure why messages are not delivered to this subscription. I will ask the service team to help us diagnose this further.

yuth avatar Jul 02 '20 23:07 yuth

@cjsedwards Do you have multiple subscriptions running at the same time? For instance one of the sub has channelId as parameter and others don't have it

yuth avatar Jul 03 '20 00:07 yuth

Yes, my Vue app has a subscription to onCreateUnreadMessageCount, onUpdateUnreadMessageCount, and onDeleteUnreadMessageCount that are running at the same time.

cjsedwards avatar Jul 03 '20 00:07 cjsedwards

@cjsedwards could you share the query used for the subscription and the mutation that used to trigger the subscription

yuth avatar Jul 03 '20 00:07 yuth

Subscription:

{
    "query": "subscription OnNewMessage($channelID: ID!) {  onNewMessage(channelID: $channelID)}",
    "variables": {
        "channelID": "3f84f782-ab68-4135-9dc3-8041589d621b"
    }
}

Mutation:

{
    "query": "  mutation AddMessage($channelID: ID!, $content: String!) {   addMessage(channelID: $channelID, content: $content)  }",
    "variables": {
        "channelID": "3f84f782-ab68-4135-9dc3-8041589d621b",
        "content": "Test message"
    }
}

cjsedwards avatar Jul 03 '20 14:07 cjsedwards