Connecting to AWS with MQTT

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
flaviosteimacher
Posts: 1
Joined: Wed Jul 10, 2019 2:18 am

Re: Connecting to AWS with MQTT

Post by flaviosteimacher » Wed Jul 10, 2019 2:20 am

how you generate the certs files?

Jimmy_Hedman
Posts: 1
Joined: Fri Nov 18, 2016 6:16 am

Re: Connecting to AWS with MQTT

Post by Jimmy_Hedman » Tue Sep 03, 2019 8:30 pm

To be able to connect to AWS with an ESP8266 you need to convert the certificatefile and the keyfile to DER format. See https://github.com/micropython/micropyt ... -453802236

shafik
Posts: 1
Joined: Wed Oct 02, 2019 11:49 am

Re: Connecting to AWS with MQTT

Post by shafik » Sun Oct 06, 2019 4:06 am

IndexError: list index out of range
This is my code:

Code: Select all

# certificate and private key 
KEY_PATH = "/619e3d582c-private.pem.key"
CERT_PATH = "/619e3d582c-certificate.pem"

with open(KEY_PATH, 'r') as f:
  PVT_KEY = f.read()
  
with open(CERT_PATH, 'r') as f:
  CERT_KEY = f.read()


client = MQTTClient(client_id="esp32_micropython_shafik",
                   server="xxxxxxxxxxxxxxxx-ats.iot.eu-west-1.amazonaws.com",
                   port = 8883,
                   keepalive = 10000,
                   ssl = True,
                   ssl_params = {
                     "cert": CERT_KEY,
                     "key": PVT_KEY,
                     "server_side":False
                   } )
I am getting continuously error in umqtt/simple.py in 57 no line, where socket.getaddrinfo(hostname, port)[0][-1] unable to parse ip address of the host name and returns a empty list. so it is giving IndexError: list index out of range !
How can I solve this?

Post Reply