AWS MQTT TCP receive error

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GrMa_3786076
Level 1
Level 1
First like received

This post acts as a solution to an error found when running through the WICED 101 AWS integration which can be found here: CypressAcademy_WW101_Files/WW101-07c-MQTT-AWS.pdf at master · cypresssemiconductorco/CypressAcademy_...

The AWS examples, publisher.c and subscriber.c, were programmed to a Quicksilver Eval kit using WICED 6.2.1.

When the board was first programmed with publisher.c, the terminal output after initialization read:

[MQTT-LIB] TCP receive error

[AWS/MQTT] Event received 2

[Application/AWS] Closing connection...

[Application/AWS] Deinitializing AWS library...

Event received 2 corresponds to WICED_MQTT_EVENT_TYPE_DISCONNECTED which the full comment is then "Event sent when broker accepts DISCONNECT request or when there is any network issue." There are a couple of settings that need to be double checked to get around this error.

First is to check that QoS is set to the correct level. In application_start() within the while(1) loop there is a function call to wiced_aws_publish. You must ensure that the QoS being passed in is set to WICED_AWS_QOS_ATMOST_ONCE. The line taken directly from publish.c should read:

ret = wiced_aws_publish( aws_connection, WICED_TOPIC, (uint8_t *)msg, strlen( msg ), WICED_AWS_QOS_ATMOST_ONCE );

Another factor to consider is that all of the time-zones match between your AWS dashboard and the code for publisher or subscriber. By default the AWS MQTT broker address is set with east-1.

Lastly, in the user guide, on step 8, you make a policy for the IoT device. The Resource ARN should be set to '*'. When I checked on the policy created, the Resource ARN field had changed or was not set properly. After editing the policy back to '*', everything worked with publisher and subscriber and the return message in the terminal was [AWS/MQTT] Event received 1.

Below are the steps to edit the policy:

  • In AWS, navigate to Manage > Things.
  • Click on your thing.
  • Click on the Security tab.
  • Click on your certificate located there.
  • Click on the Policies tab.
  • Click on your policy located there.
  • Click on Edit policy document.
  • Change the line to in the Statement to “Resource”: “*”
  • Click Save as new version.
  • Re-program the Quicksilver board and it should be good-to-go.

screenshot.jpg

0 Likes
1 Reply
RaktimR_11
Moderator
Moderator
Moderator
500 replies posted 250 replies posted 100 replies posted

Thanks a lot for enriching our community with the detailed debug steps.

0 Likes