aws-mqtt-client icon indicating copy to clipboard operation
aws-mqtt-client copied to clipboard

Stuck on 101 Switching Protocols

Open pentateu opened this issue 8 years ago • 7 comments

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?

screen shot 2016-12-13 at 1 43 33 pm

pentateu avatar Dec 13 '16 00:12 pentateu

@pentateu This is probably related to AWS policies. Check that assigned role has AWSIoTDataAccess policy. This could help - http://stackoverflow.com/a/40305905/5444431

jimmyn avatar Jan 11 '17 14:01 jimmyn

I met the same problem when i use Aliyun Message Queue.This is because the topic is invalid, hope helpful.

hezhii avatar Feb 02 '18 02:02 hezhii

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.

thomassimko avatar Feb 13 '18 23:02 thomassimko

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

Tee88 avatar Feb 16 '18 09:02 Tee88

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.

thomassimko avatar Feb 16 '18 18:02 thomassimko

I am having exactly the same issue. I can't see any errors or warnings.

pzawadzkipz avatar Apr 16 '19 14:04 pzawadzkipz

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.

blakeage avatar Jul 12 '21 18:07 blakeage