React Native: "AMQJS0007E Socket error:undefined."
See original GitHub issueDescribe 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:
- Created 4 years ago
- Reactions:1
- Comments:16 (2 by maintainers)
Top 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 >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
Can you try removing
Auth.configure();
.The above
configure
should handle Auth configuration.If this still does not work, could you try moving
above
Amplify.configure({...})
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.