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.

PubSub Websocket: "AMQJS0008I Socket closed." when trying to subscribe

See original GitHub issue

Describe the bug I followed the tutorial to create Auth for my React App, then I followed the tutorial on using PubSub with AWS IoT. The first Problem I encountered was that using the pubsub endpoint: wss://xxxxxxx-iot.eu-central-1.amazonaws.com/mqtt resulted in a “legancy certificate error” (I am using chrome) so i replaced the endpoint with wss://xxxxxxx-ats.iot.eu-central-1.amazonaws.com/mqtt. Now as soon as I try to subscribe I get the following error: {invocationContext: undefined, errorCode: 8, errorMessage: "AMQJS0008I Socket closed."}

I have attached the Policy using the command from the tutorial, but since attach-principal-policy is deprecated I also tried: aws iot attach-policy --policy-name 'myIOTPolicy' --target 'eu-central-1:xxxxxxxxxxxxxxxxxxx'

To Reproduce

  1. Follow all the steps from the tutorial for setting up a react app, adding auth and using PubSub. Expected behavior A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: WSL
  • Browser Chrome
  • Version 71.0.3578.98

This might be just an issue with the documentation

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:15

github_iconTop GitHub Comments

10reactions
1f47acommented, Apr 17, 2019

I was able to resolve this error by attaching the AWSIoTDataAccess policy to the Cognito AuthRole

7reactions
Caycecommented, Jun 5, 2019

Had the same error, changing IOT Core policy solved the problem for me:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iot:*",
      (NOT WORKS) "Resource": "arn:aws:iot:us-west-2:XXXXXXXX/*"
      (WORKS) "Resource": "*"
    }
  ]
}

My guess is that previous policy gave permission to subscribe/publish to topics, but didn’t gave the permission to connect. Amplify JS PubSub docs can be improved IMHO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

amazon web services - AWS IoT - AMQJS0008I Socket closed
I am trying to configure AWS IoT to use ...
Read more >
getting AMQJS0008I Socket closed - Google Groups
I am getting AMQJS0008I Socket closed when ever I tried connecting from client using websocket. In Server it is throwing following log.
Read more >
PubSub - AWS IoT
PubSub is available with AWS IoT and Generic MQTT Over WebSocket Providers. ... your browser console: errorCode: 8, errorMessage: AMQJS0008I Socket closed.
Read more >
How to set up #aws #iot #pubsub using #AwsAmplify sdk?
How to subscribe to a topic using aws iot and amplify? ... (in promise): Object: {"errorCode":8,"errorMessage":"AMQJS0008I Socket closed."}.
Read more >
PubSub - Getting started - JavaScript - AWS Amplify Docs
PubSub is available with AWS IoT and Generic MQTT Over WebSocket Providers. ... your browser console: errorCode: 8, errorMessage: AMQJS0008I Socket closed.
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