Amplify-js: Amplify PubSub not compatible with Amplify API GraphQL / Appsync

Created on 11 May 2018  路  3Comments  路  Source: aws-amplify/amplify-js

Feature Request - enable PubSub to work along side GraphQL/Appsync

Having a REST API, I added PubSub and observed the expected PubSub functionality when unauthenticated, and after adding both IAM and IOT policies and attaching the Cognito ID of each subscriber, I also observed expected PubSub functionality when authenticated.

Having upgraded from REST to AppSync/GraphQL, I observe the desired Query and Mutation behaviour. Despite many subscription/authorization patterns available, as far as I can tell the GraphQL subscription mechanism will not be flexible enough to meet my authorization needs.

In order to meet my needs, I returned to the more generic PubSub. But I have discovered that under the same PubSub configuration, the PubSub functionality that worked along side REST no longer works along side GraphQL. I suspect that Amplify PubSub and Amplify API GraphQL have contention in using the same MQTT/WebSocket resources.

I have the correct PubSub configuration:

Amplify.addPluggable(
  new AWSIoTProvider({
    aws_pubsub_region: <my region>
    aws_pubsub_endpoint: <my endpoint>
  })
);

With GraphQL (but not with REST) subscribing to a PubSub Topic results in this error:
Error: Missing connections info
at AWSAppSyncProvider../node_modules/aws-amplify/lib/PubSub/Providers/AWSAppSyncProvider.js.AWSAppSyncProvider.subscribe (AWSAppSyncProvider.js:75)

AppSync PubSub bug tracked

Most helpful comment

Any update on this? Everything works fine with PubSub when there is no GraphQL added via Amplify. However when using GraphQL and using:
Amplify.addPluggable( new AWSIoTProvider({ aws_pubsub_region: "eu-west-1", aws_pubsub_endpoint: "wss://<yourstuff>.iot.eu-west-1.amazonaws.com/mqtt" }) );

It results in a missing connections info error.

All 3 comments

Any update on this? Everything works fine with PubSub when there is no GraphQL added via Amplify. However when using GraphQL and using:
Amplify.addPluggable( new AWSIoTProvider({ aws_pubsub_region: "eu-west-1", aws_pubsub_endpoint: "wss://<yourstuff>.iot.eu-west-1.amazonaws.com/mqtt" }) );

It results in a missing connections info error.

Bruh, this issue is still unsolved... I may have to roll up my sleeves real soon. I was hoping someone would have done the dirty work by now.

I can confirm that:

  • Aws IOT works fine on its own
  • AWS AppSync works fine on its own
  • AWS IOT + AppSync results in IOT not working at all, however AppySync non-socket related stuff like mutations and queries work fine, But subscriptions, which use sockets does work.

Perhaps they are fighting for the same socket resource which doesnt allow for them to simultaneously use them.

this is the line that's producing the error in AWSAppSyncProvider.js:

newAliases = Object.entries(newSubscriptions)

It appears that AppSync is the one that's breaking because of AWS IOT.

The code in IOT that causes AppSync to break is:

PubSub.subscribe("rice").subscribe({})

when setting up a pubsub connection.

@Matthcw we are working on it. @manueliglesias will work on this.

Was this page helpful?
0 / 5 - 0 ratings