This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

mqtt_simple connect to AWS

I have an AWS account and I am comfortable with the AWS IOT operation in general. I have used it in the past. I am trying to get the sample mqtt_simple to connect to AWS IOT and be able to send packets and receive packets to the nRF9160dk board.

 I am not sure how to set up mqtt_simple parameters? I have created a thing and certificates. I have named the thing "nrf-IMEI" as recommended so it has the board ID in it. All I want to do is to be able to publish a packet to a topic on my AWS account and receive a packet from a topic in my AWS account. I have done this several times in the past with other systems so I am comfortable with AWS IOT operations and formats. I just do not understand how to get mqtt_simple to publish from my board to AWS and subscribe to messages from AWS.

Is this the correct program to use. It seems like all the pieces are there I just do not know how to use them.

I appreciate any help you can give, This is an essential requirement of our production system. right now we are using the pre-production system with a modified version of asset_tracker to send sensor data to the nRF Connect site. We need to be able to send sensor data to our AWS site.

  • the mqtt_simple_aws is trying to connect to something as I indicated in the last post. Is there a way to look at any error messages at the AWS->cloudwatch->log messages to see why AWS is not happy. I see log messages in the log page but we are using it constantly so there are many iot messages from our current systems. How can I find the one from the mqtt_simple_aws program easily.

  • I started from the beginning and crested a new thing, certificates, etc. I loaded the certificates onto the board using LTE connect application. The results were the same for mqtt_simple_aws as shown below. Any idea how I find out why it is not connecting? I feel I am very close just missing something simple that I am not setting up correctly.

    *** Booting Zephyr OS build v2.1.99-ncs1 ***
    The MQTT simple AWS sample started
    LTE Link Connecting ...
    LTE Link Connected!
    IPv4 Address found 34.225.159.102
    ERROR: mqtt_live -57
    Disconnecting MQTT client...
    Could not disconnect MQTT client. Error: -57

  • I added some print statements to see if that shed more light on the problem. I also added a check for the POLLHUP received in the code you sent me..

    Note that The LTE link is connected, we get an IPv4 address, the mqtt_connect passes (I assume the client_init passes also but it does not return an error. the fds_init passes and the poll passes but it immediately returns a POLLHUP ("Connection was closed by the cloud.").

    does this mean we tried to make a connection to AWS and it was refused. any ideas where to look? is there a way to see in AWS that it saw this request and rejected it and why? error -57 is "Socket is not connected". does this help?

    *** Booting Zephyr OS build v2.1.99-ncs1 ***
    The MQTT simple AWS sample started
    LTE Link Connecting ...
    LTE Link Connected!
    IPv4 Address found 34.202.74.240
    mqtt_connect passed
    fds_init passed
    poll passed
    fds.revents 0x10
    POLLHUP
    Disconnecting MQTT client...
    Could not disconnect MQTT client. Error: -57

  • I was able to get the mqtt_simple_aws sample program to work. A colleague found it needed some code associated with LTS that was missing in client_init. 

  • Hi Timothy,
    Fantastic to hear that you were able to use it with some modifications. 


    I would appreciate it if you could post the snippet that was missing so I could update the code on the github page.

Related