Using subscriptions from nodejs throws `"errorMessage": "AMQJS0007E Socket error:undefined.",`
See original GitHub issueI 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:
- Created 5 years ago
- Comments:12 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 changesThis 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?