This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220S-LAUNCHXL: AWS Publish-Subscribe example - MQTTcallbackHandler not called

Part Number: CC3220S-LAUNCHXL

I have successfully built and tested the AWS Publish and Subscribe example see serial output below...

CC3220 has connected to AP and acquired an IP address.

IP Address: 192.168.43.111

Current time: Wed May 24 15:38:47 2017

Flashing certificate file ...
successfully wrote file /cert/ca.der to flash

Flashing certificate file ...
successfully wrote file /cert/cert.der to flash

Flashing certificate file ...
successfully wrote file /cert/key.der to flash

AWS IoT SDK Version 2.1.1-

Connecting...

Subscribing...

-->sleep

-->sleep

I can see the messages are published on AWS by the client, but there are no Subscribe messages back from the sdkTest/sub topic.  I have tried publishing a message to the same topic from the test feature within AWS console, but still no subscribed messages. I tried a breakpoint in the MQTTcallbackHandler but its never called.

Are there any issues with this new version of the example?  Is there something else I need to do on AWS to trigger subscribe messages?

Regards

Tony

  • Hi Tony,

    What does your AWS policy look like?

    I'm guessing you don't have the policy set correctly.  Since you're able to publish (you see the messages published by your 3220 device on the AWS server's MQTT client), it's likely due to the receive or subscribe policy. Details on that here.

    This thread discusses setting a very open AWS policy, so if yours is different you might try setting it as shown there.

    Steve

  • Thanks Steven,

    You were correct, I had set the Subscribe policy, but not the iot:receive policy.

    This critical step is missing from the Quick Start Guide, and the AWS IoT Button documentation linked in the guide, and might be worthy of a note in the documentation.

    Best Regards

    Tony
  • Hello Tony,

    Thanks for the feedback - that's very useful.

    Would you mind posting the default policy that was assigned to your 'thing' here for reference please?

    Thanks!
    ~roger
  • Hello Tony,

    I think I see the difference here.  When using the 'old' console, a default policy is applied when the certificates are generated (as below).

    This policy is pretty open as follows :-

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Action": [
            "iot:*"
          ],
          "Resource": [
            "*"
          ],
          "Effect": "Allow"
        }
      ]
    }

    However, when using the 'new' console, a default policy is not attached, and needs to be manually assigned (better for security in general, but not so good for quick-start). 

    I presume you used the 'new' console, which would make sense.

    ~roger

  • Hi Roger,

    Here is the policy I created which is much more restrictive but now seems to work OK...

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": "iot:Connect",
          "Resource": "arn:aws:iot:eu-west-2:xxxxxxxxxxxx:client/CC3220_XXXXXX"
        },
        {
          "Effect": "Allow",
          "Action": "iot:Subscribe",
          "Resource": "arn:aws:iot:eu-west-2:xxxxxxxxxxxx:topicfilter/sdkTest/sub"
        },
        {
          "Effect": "Allow",
          "Action": "iot:Publish",
          "Resource": "arn:aws:iot:eu-west-2:xxxxxxxxxxxx:topic/sdkTest/sub"
        },
        {
          "Effect": "Allow",
          "Action": "iot:Receive",
          "Resource": "arn:aws:iot:eu-west-2:xxxxxxxxxxxx:topic/sdkTest/sub"
        }
      ]
    }

    regards

    tony

  • Thanks for confirming and sharing Tony.

    That's a much better policy to match the publish_subscribe example.
    I'm sure you're already aware, but for the examples that use shadow support, those topics would need to be opened up as as well.

    Hope the project goes well!
    ~roger