peterhinch / micropython-mqtt

A 'resilient' asynchronous MQTT driver. Recovers from WiFi and broker outages.
MIT License
580 stars 127 forks source link

Trying to connect with AWS iot Core using mqtt_as library but getting error #146

Open meet1227 opened 4 months ago

meet1227 commented 4 months ago

I'm encountering an issue while using the tls.py example code with a library. I've configured the ca, cert, and key fields as per thing in AWS iot core. When attempting to connect to the server, I'm getting the following error:
OSError: (-17168, 'MBEDTLS_ERR_RSA_PRIVATE_FAILED+MBEDTLS_ERR_MPI_ALLOC_FAILED')

OUTPUT:

Checking WiFi integrity.
Got reliable connection
Connecting to broker.
Traceback (most recent call last):
  File "<stdin>", line 136, in <module>
  File "asyncio/core.py", line 1, in run
  File "asyncio/core.py", line 1, in run_until_complete
  File "asyncio/core.py", line 1, in run_until_complete
  File "<stdin>", line 111, in main
  File "mqtt_as.py", line 655, in connect
  File "mqtt_as.py", line 284, in _connect
OSError: (-17168, 'MBEDTLS_ERR_RSA_PRIVATE_FAILED+MBEDTLS_ERR_MPI_ALLOC_FAILED')
please help me in this issue

I am using ESPwroom32 hardware.

peterhinch commented 4 months ago

It might be worth also posting in Discussions as there may be someone with experience of AWS iot core.

bobveringa commented 3 months ago

The devices I work on also connect to AWS IoT core. We most often see this error when there is not enough (continuous) memory to allocate to storing some of the SSL things in memory. I think MicroPython v1.21 was the most problematic version, and more recent versions don't have this issue.

Try checking how much memory is used/available before you attempt to connect.

Also, are you using frozen bytecode?