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

    AWS iot socket create error: -8567

    Scheduled Pinned Locked Moved LoPy
    awsiotlopy
    12 Posts 3 Posters 2.6k Views 4 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.
    • V Offline
      Vicky_
      last edited by

      I have tried to connect my LoPy to AWS IoT follow this tutorial https://docs.pycom.io/chapter/tutorials/all/aws.html.

      The main.py I did not change and this is part of my config.py coding.

       # AWS general configuration
      AWS_PORT = 8883
      #AWS_HOST = 'aws_host_url'
      AWS_HOST = 'a2ny4s7pewp2cl.iot.ap-southeast-1.amazonaws.com'
      AWS_ROOT_CA = '/flash/cert/VeriSign-Class 3-Public-Primary-Certification-Authority-G5.pem'
      AWS_CLIENT_CERT = '/flash/cert/4aecbe1ac8-public.pem.key'
      AWS_PRIVATE_KEY = '/flash/cert/4aecbe1ac8-private.pem.key'
      
      ################## Subscribe / Publish client #################
      #CLIENT_ID = 'PycomPublishClient'
      CLIENT_ID = 'iotconsole-15215624106470-2'
      TOPIC = 'PublishTopic'
      OFFLINE_QUEUE_SIZE = -1
      DRAINING_FREQ = 2
      CONN_DISCONN_TIMEOUT = 10
      MQTT_OPER_TIMEOUT = 5
      LAST_WILL_TOPIC = 'PublishTopic'
      LAST_WILL_MSG = 'To All: Last will message'
      

      Below is the error i got. I have opened the port 8883

      alt text

      if I leave it, after few minutes it will become

      alt text

      Any idea what these errors mean? Thanks.

      T 1 Reply Last reply Reply Quote 0
      • T Offline
        timh @Vicky_
        last edited by

        @vicky_ I have been playing with the core of this lib to talk to Losant.

        I found a few things that seem to have a problem. Firstly the msgHandler has no connect method (which is called when it tries to reconnect in verify_connection method).

        It also seems that if you disconnect the thread is still running trying to send keepalive packets. I had to make some changes so that if service is disconnected explicitly , that the thread exits, and then when you explicitly connect it recreates the thread. I am sure there are a few other corner cases in their in the event of disconnect.

        I am not really sure what the best way to re-structure the code at the moment so haven't suggested anything as yet.

        V 1 Reply Last reply Reply Quote 1
        • V Offline
          Vicky_ @timh
          last edited by Vicky_

          @timh thanks for your quick response! However, I am new to micropython, iot and LoRa, cant fully understand what you mean. Is there another way you can suggest me to connect my LoPy to the internet? I tried LoRaWAN nanogateway but the OTAA/ABP node script doesn't work for my region. Thanks :)

          T 1 Reply Last reply Reply Quote 0
          • T Offline
            timh @Vicky_
            last edited by

            @vicky_ Hi Vicky socket errors generally mean the connection to AWS has failed. . You could try reconnecting , or reducing the keep alive interval. Once you perform the initial connect have you been able to publish any data to AWS successfully

            V 1 Reply Last reply Reply Quote 0
            • V Offline
              Vicky_ @timh
              last edited by Vicky_

              @timh Hi Timh. How can I reduce the keep alive interval? Reduce the loopcount in main.py or draining_Freq/ Conn_disconn_timeout/ Mqtt_oper_timeout in config.py? No, never publish any data to AWS successfully before. :(

              T 2 Replies Last reply Reply Quote 0
              • T Offline
                timh @Vicky_
                last edited by

                @vicky_ Oh, if you haven't been able to publish, it means your connection isn't succeeding.

                It does retry for some time, hence the wait.

                I take it you have got a working network connection ?

                Not sure what -8567 is. Need to look at where in the socket lib that is coming from.

                1 Reply Last reply Reply Quote 0
                • T Offline
                  timh @Vicky_
                  last edited by

                  @vicky_ Oh. What is your network connection ? WIFI ?

                  V 1 Reply Last reply Reply Quote 0
                  • V Offline
                    Vicky_ @timh
                    last edited by

                    @timh yes, my home wifi, I also used my phone as Hotspot. both also give the same result. yes is working as you can see in the console the first line is 'WLAN connection succeded!" I also cant find out what -8567 is.

                    T 1 Reply Last reply Reply Quote 0
                    • T Offline
                      timh @Vicky_
                      last edited by

                      @vicky_ Do you have another platform from python (raspberrypi or windows) where you can check that you can connect to AWS IOT via mqtt using the same certs, hosts etc....

                      The process is pretty much identical on any other python platform. https://github.com/aws/aws-iot-device-sdk-python

                      If you can then you know you have your config correct. both locally and on AWS.

                      I am connecting using MQTT over WIFI and LTE CAT-M1 to Losant successfully. But I am only using a ROOT_CA.

                      V 2 Replies Last reply Reply Quote 0
                      • V Offline
                        Vicky_ @timh
                        last edited by

                        @timh thanks Timh for your suggestion. I don't have raspberrypi but I will try windows and let you know how it goes. Thanks a lot!

                        1 Reply Last reply Reply Quote 0
                        • V Offline
                          Vicky_ @timh
                          last edited by

                          @timh hello timh. sorry for late reply. I didn't try using window to connect to aws iot because it seems complicated and difficult to me. However, I tried ubidots and adafruit mqtt. both work. :D

                          1 Reply Last reply Reply Quote 0
                          • C Offline
                            cirobr
                            last edited by

                            Hello,

                            I bumped on this very same issue when executing the below (partial) code. The socket create error -8576 showed up upon every attempt of executing the loop:

                            while not pycomAwsMQTTClient.connect():
                                print("Waiting for AWS...")
                                time.sleep(10)
                            print('AWS connection succeeded!')
                            

                            Have found that the problem was on the root CA certificate. Just to recap, AWS "setup.py" file expects to work with three certificates as follows:

                            AWS_ROOT_CA = "/flash/cert/root-CA.crt"
                            AWS_CLIENT_CERT = "/flash/cert/thing.cert.pem"
                            AWS_PRIVATE_KEY = "/flash/cert/thing.private.key"
                            

                            For some reason the root certificate was not created correctly upon instructions from AWS tutorials. To fix that, run the below command line on a Linux Terminal to download it again:

                            curl https://www.amazontrust.com/repository/AmazonRootCA1.pem > root-CA.crt
                            

                            By doing so, my issue was fixed.

                            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