I am trying to connect to my broker using MQTT from my ESP32 chip. After uploading the the file and run it from puTTy repl
I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "main3.py", line 35, in <module>
File "umqtt/simple.py", line 57, in connect
IndexError: list index out of range
well, when I brows the directory with:
import os
os.listdir()
I don't see any umqtt directory and no file named simple.py!!!. where are these files or directory coming from in the error MSG if I don't have them in my ESP32
microelectronic? any suggestion?
Thank you
Missing py file
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Missing py file
you have to put them onto your device.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Missing py file
The module is frozen as bytecode: standard firmware builds include some modules compiled into the build. If you issue
you should see simple as part of the output.
The failing line is
I would check your server and port settings. It would help us figure out why this is failing if you posted your code.
Code: Select all
help('modules')
The failing line is
Code: Select all
addr = socket.getaddrinfo(self.server, self.port)[0][-1]
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 3
- Joined: Mon Aug 20, 2018 2:33 pm
Re: Missing py file
Hi pythoncoder,
Thanks for the useful information. You actually answered couple of my other questions.
My dilemma is connecting my ESP32 to AWS IoT.
I get [Errno 113] EHOSTUNREACH, which I think that there is an issue with handshake with AWS:
I am using this code:
CACERT_PATH = "/flash/root.pem"
KEY_PATH = "/flash/49c84a8c4a-private.key"
CERT_PATH = "/flash/49c84a8c4a-certificate.pem"
with open(KEY_PATH, 'rb') as f:
key1 = f.read()
with open(CACERT_PATH, 'rb') as f:
key2 = f.read()
with open(CERT_PATH, 'rb') as f:
cert1 = f.read()
client = MQTTClient(client_id="youraccount/feeds/lights", server="a21sigud7911d7.iot.us-west-2.amazonaws.com", port=0, keepalive=4000, ssl=False, ssl_params={ "key":key1, "cert":cert1, "server_side":True })
I posted a topic a few days back but no replies. I spent a few days struggling/changed the code and setting with no luck
Do you have any idea why I can talk to AWS?
Thanks in advance
Thanks for the useful information. You actually answered couple of my other questions.
My dilemma is connecting my ESP32 to AWS IoT.
I get [Errno 113] EHOSTUNREACH, which I think that there is an issue with handshake with AWS:
I am using this code:
CACERT_PATH = "/flash/root.pem"
KEY_PATH = "/flash/49c84a8c4a-private.key"
CERT_PATH = "/flash/49c84a8c4a-certificate.pem"
with open(KEY_PATH, 'rb') as f:
key1 = f.read()
with open(CACERT_PATH, 'rb') as f:
key2 = f.read()
with open(CERT_PATH, 'rb') as f:
cert1 = f.read()
client = MQTTClient(client_id="youraccount/feeds/lights", server="a21sigud7911d7.iot.us-west-2.amazonaws.com", port=0, keepalive=4000, ssl=False, ssl_params={ "key":key1, "cert":cert1, "server_side":True })
I posted a topic a few days back but no replies. I spent a few days struggling/changed the code and setting with no luck
Do you have any idea why I can talk to AWS?
Thanks in advance
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
SSL/TLS
The last time I tried I made no headway with TLS and could only connect to unencrypted brokers. Since then I gather TLS support has improved: hopefully someone with recent experience will advise.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 3
- Joined: Mon Aug 20, 2018 2:33 pm
Re: Missing py file
Got it, Thanks for quick response
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Missing py file
Sorry, I obviously did not read it correctly. Glad pythoncoder could help quickly.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode