9

I am calling this graphql subscription on my react app:

export const OnCreateMessage = `
  subscription OnCreateMessage($conversationId: ID!) {
    onCreateMessage(messageConversationId: $conversationId) {
      id
      content
      authorId
      messageConversationId
      createdAt
    }
  }
`

This is how I call it inside a class component:

API.graphql(
    graphqlOperation(subscriptions.OnCreateMessage, {conversationId: "c074c7b7-f6db-459a-a1d8-cd290aee33ea"})
  ).subscribe({
    next: ({ provider, value }) => console.log({provider, value}),
    error: error => console.warn("did not get messages")
});

However, when I run my app and this is called, I get this error on my network tab:

{
  "errors" : [ {
    "errorType" : "BadRequestException",
    "message" : "Subscriptions over MQTT is not supported."
  } ]
}

I saw on the AWS docs that "MQTT over WebSockets will no longer be available for new AppSync APIs" but I don't know what to do now.

Can someone look into this and help me out?

Mikey K
  • 91
  • 1
  • 3
  • We're also experiencing this issue at the moment. MQTT has been deprecated on all new APIs as well as new regions (https://docs.aws.amazon.com/appsync/latest/devguide/aws-appsync-real-time-data.html). Just wish AWS had better library support! – Alex May 21 '21 at 10:55
  • I imagine you are using AWSAppSyncClient (https://github.com/awslabs/aws-mobile-appsync-sdk-js/blob/fc173bfe3ce262b1dba422021fc57097c4926b7b/packages/aws-appsync/src/client.ts#L171) from the aws-appsync (https://www.npmjs.com/package/aws-appsync) package? If so, what version of the package are you using? I recommend updating to the latest version as you may be out of date. – kcstricks Jun 17 '21 at 06:16

1 Answers1

3

I'm not sure if you found an answer to this, but we are facing the same thing with a project and it requires that you use a GraphQL client that can handle subscriptions over pure WebSockets. See the answer to this question about using the AWS AppSync client.

Adam Greene
  • 116
  • 7