Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    UMQTT & AWS IoT

    Scheduled Pinned Locked Moved Guides
    mqttmicropythonawsumqttssl
    5 Posts 4 Posters 4.0k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      juriw
      last edited by

      Hi, everyone!

      AN HOW-TO-GUIDE FOR UMQTT WITH AWS IOT.

      I've spent almost two days to figure this out. It's finally working so I want to share it with you guys and girls!

      The goal I had was somewhat simple, but a little tricky because of the lack of detailed documentation and almost no posts about the issues in general. Here on the forum, some have posted parts of my solution but no one directly about UMQTT and SSL connection.

      The posts I found related here on the forum was;
      On UMQTT: https://forum.pycom.io/topic/211/simple-mqtt-tutorial
      On SSL: https://forum.pycom.io/topic/320/q-ussl-usage-for-https-problem
      On AWS IoT: https://forum.pycom.io/topic/352/aws-iot-device-support-for-lopy

      Back to the goal I had. I wanted to do the following;

      1. Get my SiPy to communicate with AWS IoT through UMQTT (Link to umqtt.simple lib: https://goo.gl/0Umf9Y )
      2. Subscribe the UMQTT topic on my AWS account.

      Follow This

      Setup AWS certificates by following the steps in this https://goo.gl/Qu5Zs3 tutorial. I will advise to download the project code and make it run on your machine (PC). This project runs with regular MQTT for Python, when you have this project running you know that certificates on AWS are correct setup.

      The following https://goo.gl/eCFlRq pictures shows how your AWS IoT section should look like after completion of the before mentioned tutorial (commands done with AWS CLI).

      The Code

      Download and look it over. Code: https://github.com/juwul/umqtt_aws_iot

      Some tips I found.

      1. The keepalive param on the MQTT connection should be high because it may take some time for the certificates to be verified.
      2. Do not split up the SSL configurations and the construction of MQTTClient. I saw some example in my search for solutions where first the certification configurations are set and afterward the connection is called or vice versa. Once again I did not have any luck with those type of settings so I will recommend to set it up with ssl_params in the construction call. For reference see the note by user @daniel in this post: https://forum.pycom.io/topic/320/q-ussl-usage-for-https-problem/4
        Daniel explains that the SSL handshake needs to be done while connecting as I do (minor differences because it’s sockets, but you get the point).

      Thanks to

      Mario Cannistrà – Profile: https://www.hackster.io/mariocannistra for the easy step-by-step AWS CLI instructions and to @daniel's note about doing SSL handshake in the right way order.

      1 Reply Last reply Reply Quote 5
      • B Offline
        bucknall
        last edited by

        Hi @juriw

        Thanks for sharing this! I'm sure this will be of great help to many people! :)

        Developer Evangelist - Pycom

        J 1 Reply Last reply Reply Quote 0
        • J Offline
          juriw @bucknall
          last edited by juriw

          @bucknall Hi and thanks.

          To all following the guide please share results. I did not have a board available when I finished up the code so some confirmation on it running would be great :)

          1 Reply Last reply Reply Quote 1
          • H Offline
            haxpanel
            last edited by

            I'm getting the following error: TypeError('extra keyword arguments given). After some investigation it turns out that the error comes from the SSL socket wrapper: self.sock = ussl.wrap_socket(self.sock, **self.ssl_params).
            How did you manage to make it connect?
            Thanks!

            1 Reply Last reply Reply Quote 0
            • F Offline
              fausto.milletari
              last edited by

              Hello,

              i am trying very hard to subscribe to a topic and actually receive something. I am using the integrated client on the AWS side to debug.

              i am observing that i am successful when it comes to publishing topics. It works well.
              If i subscribe to a topic i just do not receive anything at all.

              I have tried with both simple and the guide in the pycom documentation. I suspect at this point a misconfiguration from the side of AWS.

              I have permission in my policy to subscribe to any resource. Subscription itself works.

              No messages are ever displayed though. Callback is never called.

              any help is appreciated!

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • 1 / 1
              • First post
                Last post

              Pycom on Twitter

              Pycom