question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using subscriptions from nodejs throws `"errorMessage": "AMQJS0007E Socket error:undefined.",`

See original GitHub issue

I am trying to test my subscriptions in nodejs,

I am logging in first,

let cognitoId = null;
let client: any = null;

beforeAll(() => {
  global.fetch = fetch;
  Amplify.configure(AmplifyConfig);

  client = new AWSAppSyncClient({
    disableOffline: true,
    url: AmplifyConfig.aws_appsync_graphqlEndpoint,
    region: AmplifyConfig.aws_appsync_region,
    auth: {
      type: AmplifyConfig.aws_appsync_authenticationType,
      credentials: () => Amplify.Auth.currentCredentials(),
    },
  });

  return Promise.resolve()
    .then(() => Auth.signIn(USER.username, USER.password))
    .then(result => {
      expect(result.username).not.toBeNull();
      cognitoId = result.username;
    });
});

I then do a couple of mutations and queries which are all working fine, but when I try to test the subscription

let hydratedClient: any = null;
return Promise.resolve()
  .then(() => client.hydrated())
  .then(client => (hydratedClient = client))
  .then(() => {
    hydratedClient.query;

    hydratedClient
      .subscribe({
        query: NewMessageSubscription,
      })
      .subscribe({
        next: data => {
          console.log('Data', data);
        },
        onError: data => {
          console.log('Error', data);
        },
      });

    return hydratedClient
      .mutate({
        mutation: InsertMessage,
        variables: { message },
      })
      .then(result => {
        expect(result.data.insertMessage).toEqual(
          expect.objectContaining(message),
        );

        // Give it time to break
        setTimeout(done, 2000);
      });
  });

This throws an error though

    thrown: Object {
      "errorCode": 7,
      "errorMessage": "AMQJS0007E Socket error:undefined.",
      "invocationContext": undefined,
    }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nicklaroscommented, Nov 14, 2018

confirmed using ws lib version ^4.0.0 and it works fine. but not with ^5.0.0, I guess it is related with some major version breaking changes

1reaction
undefobjcommented, Nov 12, 2018

This could be the version of the websocket lib you have installed in node as a specific polyfill is needed. If you look here: https://docs.aws.amazon.com/appsync/latest/devguide/building-a-client-app-node.html

You will see "ws": "^3.3.1".

Could you try the instructions listed on that page?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connect failed: AMQJS0007E Socket error:undefined
I got the error message: Connect failed: AMQJS0007E Socket error:undefined. I have the MQTTX client works with the mosquitto broker/server.
Read more >
React Native AWS Amplify PubSub error: "AMQJS0007E ...
I then added the IoTDataAccess policy to the role and then retried the publish and subscription and it seemed to work.
Read more >
Guide to building a React Native MQTT messaging app
In this article, we'll demonstrate how to set up an MQTT broker to subscribe and publish topics to iOS and Android apps using...
Read more >
408078 – Client throws exception on connect error - Bugs
LOG: Object {invocationContext: undefined, errorCode: 7, errorMessage: "AMQJS0007E Socket error:undefined."} In FF - If the server/port doesn't exist, ...
Read more >
Using MQTT Over WebSockets with Mosquitto
See Using the Node.js MQTT Client-Starting Guide. Was This Useful? ... On connect I receive error 7, “AMQJS0007E Socket error:undefined.”.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found