Missing py file

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
armon75226
Posts: 3
Joined: Mon Aug 20, 2018 2:33 pm

Missing py file

Post by armon75226 » Mon Aug 20, 2018 2:40 pm

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

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Missing py file

Post by kevinkk525 » Tue Aug 21, 2018 7:46 am

you have to put them onto your device.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Missing py file

Post by pythoncoder » Tue Aug 21, 2018 8:03 am

The module is frozen as bytecode: standard firmware builds include some modules compiled into the build. If you issue

Code: Select all

help('modules')
you should see simple as part of the output.

The failing line is

Code: Select all

addr = socket.getaddrinfo(self.server, self.port)[0][-1]
I would check your server and port settings. It would help us figure out why this is failing if you posted your code.
Peter Hinch
Index to my micropython libraries.

armon75226
Posts: 3
Joined: Mon Aug 20, 2018 2:33 pm

Re: Missing py file

Post by armon75226 » Tue Aug 21, 2018 2:33 pm

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

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

SSL/TLS

Post by pythoncoder » Tue Aug 21, 2018 4:07 pm

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.

armon75226
Posts: 3
Joined: Mon Aug 20, 2018 2:33 pm

Re: Missing py file

Post by armon75226 » Tue Aug 21, 2018 4:11 pm

Got it, Thanks for quick response

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

Re: Missing py file

Post by kevinkk525 » Tue Aug 21, 2018 4:30 pm

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

Post Reply