aws-mqtt-client
aws-mqtt-client copied to clipboard
Stuck on 101 Switching Protocols
Hi,
I'm trying to follow the example in the readme, but I never get the on('connect' ..) event to be fired.
I can see that there are several connections that all end at "101 Switching Protocols".
Debugging a bit inside I noticed that the streams close as soon as they open.. and they the cycle starts again. no error and no other events are fired.
At first I had authorization errors, but after adding AWSIoTDataAccess to my role the auth issue was solved, but now I'm stuck at this point.
Did anyone experience anything similar?

@pentateu This is probably related to AWS policies. Check that assigned role has AWSIoTDataAccess
policy. This could help - http://stackoverflow.com/a/40305905/5444431
I met the same problem when i use Aliyun Message Queue.This is because the topic is invalid, hope helpful.
I am having the same issue. The issue arises when simply trying to connect to AWS IoT, not when publishing/subscribing to a specific topic.
Hello @pentateu !! This is probably your problem the answer you are looking for as stated on the official documentation page :
"For an authenticated Amazon Cognito identity to publish MQTT messages over HTTP on topic1 in your AWS account, you must specify two policies, as outlined here. The first policy must be attached to an Amazon Cognito identity pool role. It allows identities from that pool to make a publish call. The second policy must be attached to an Amazon Cognito user using the AWS IoT AttachPolicy API. It allows the specified Amazon Cognito user access to the topic1 topic."
Follow this link to see the examples on the AWS IoT Documentation https://docs.aws.amazon.com/iot/latest/developerguide/pub-sub-policy.html
The issue still persists. Both my Amazon Cognito Identity Pool Role and Cognito User have iot.* permissions. Thanks for the help.
Edit:
We have also tried to attach the iot.* policy to the user using aws cli and still no luck.
I am having exactly the same issue. I can't see any errors or warnings.
I spent a LONG time trying so many things...created new topics, created a new Federated Identity, created new roles. In the end, it was because in the policy for the federated identity (unauthenticated role), I had capitalized the "F" in "topicFilter" in the resource ARN. For example:
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": [
"arn:aws:iot:us-east-1:XXXXX:topicFilter/ManualScores/*/score",
]
}
instead of this:
{
"Effect": "Allow",
"Action": "iot:Subscribe",
"Resource": [
"arn:aws:iot:us-east-1:XXXXX:topicfilter/ManualScores/*/score",
]
}
Maybe this will help someone else.