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.

React Native: "AMQJS0007E Socket error:undefined."

See original GitHub issue

Describe the bug I am using AWS Amplify to connect to AWS IoT Core and getting error “AMQJS0007E Socket error:undefined.” I have integrated aws amplify in expo app.

Sample code

import React from "react";
import { StyleSheet, Text, View } from "react-native";
import Amplify, { PubSub, Auth } from "aws-amplify";
import { AWSIoTProvider } from "@aws-amplify/pubsub/lib/Providers";

Amplify.configure({
  Auth: {
    identityPoolId: "ap-south-1:xx-xx-xx-xx-xx",
    region: "AP_SOUTH_1",
    userPoolId: "ap-south-1_xx",
    userPoolWebClientId: "xxx"
  }
});
Amplify.addPluggable(
  new AWSIoTProvider({
    aws_pubsub_region: "ap-south-1",
    aws_pubsub_endpoint: "wss://xx.iot.ap-south-1.amazonaws.com/mqtt"
  })
);
class App extends React.Component {
  async componentDidMount() {
    Auth.configure();
    const sub1 = PubSub.subscribe("$aws/things/xxx/shadow/update").subscribe({
      next: data => console.log("Message received", data),
      error: error => console.error(error),
      close: () => console.log("Done")
    });
  }
  render() {
    return (
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
    alignItems: "center",
    justifyContent: "center"
  }
});

export default App;

Error details

  • errorCode: 7
  • errorMessage: “AMQJS0007E Socket error:undefined.”
  • invocationContext: undefined

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jordanranzcommented, Jul 29, 2019

Can you try removing Auth.configure();.

Amplify.configure({
  Auth: {
    identityPoolId: "ap-south-1:xx-xx-xx-xx-xx",
    region: "AP_SOUTH_1",
    userPoolId: "ap-south-1_xx",
    userPoolWebClientId: "xxx"
  }
});

The above configure should handle Auth configuration.

If this still does not work, could you try moving

Amplify.addPluggable(
  new AWSIoTProvider({
    aws_pubsub_region: "ap-south-1",
    aws_pubsub_endpoint: "wss://xx.iot.ap-south-1.amazonaws.com/mqtt"
  })
);

above Amplify.configure({...})

1reaction
andyautida14commented, May 11, 2021

I had the same problem, but I solved mine by using ‘iot:Data-ATS’ endpoint type instead of ‘iot:Data’. Basically, use ‘wss://xx-ats.iot.ap-south-1.amazonaws.com/mqtt’ (notice the added ‘-ats’) for your aws_pubsub_endpoint.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native AWS Amplify PubSub error: "AMQJS0007E ...
I am using AWS Amplify to connect to AWS IoT Core and getting error "AMQJS0007E Socket error:undefined." ...
Read more >
Connect failed: AMQJS0007E Socket error:undefined - HiveMQ
I got the error message: Connect failed: AMQJS0007E Socket error:undefined. I have the MQTTX client works with the mosquitto broker/server.
Read more >
Make connection between react native & raspberry & MQTT
But the connection doesn't work. Any help is appreciated. Error: Object { "errorCode": 7, "errorMessage": "AMQJS0007E Socket error:undefined.", ...
Read more >
PAHO MQTT : r/reactnative - Reddit
Nevermind, I just reinitialize the whole client, not only the connection when i get either Error: AMQJS0007E Socket error: Unknown socket ...
Read more >
AWS-Amplify/Lobby - Gitter
Any leads will be really helpful since I'm stuck at this for a really long time. amqjs0007e socket error:undefined aws-amplify/amplify-js#3653. Chris Parker.
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