adafruit / adafruit/Adafruit_CircuitPython_MiniMQTT
Errors with MQTT CircuitPython 9 Publish
- Dominant language
- Python
- Stars
- 81
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
We have an implementation of MiniMQTT that has been quite stable in CircuitPython 8 but started to display multiple issues when we tested in CircuitPython 9 (9.0.3 and below) on multiple ESP32-S3 boards.
The code base sends some API requests over HTTP GET/POST using the `Adafruit_CircuitPython_Requests` library (with no issues) and then continues on to connect to the MQTT server over SSL to send sensor observations every few seconds. We tried updating to use `adafruit_connection_manager` for `socket_pool` and `ssl_context` but this does not seem to fix the issue. We also tried to run a `reconnect()` on errors as described in #194 but no luck. It is interesting because sometimes the code runs fine for an hour or more but then most often it causes errors within the first few minutes if not immediately.
We tried various bundles both with `*.py` source code, `*.mpy` bundle pre-built and self-built `*.mpy` variations with no luck and similar observations. The bundle dates we have tried out are : `20240402`, `20240307` and `20240224`.
The most common errors seen (but not necessarily together) are :
```
OSError(11,)
OSError(104,)
MemoryError()
MMQTTException('Repeated connect failures',)
```
Less Common Errors (maybe stemming from the common errors above ? ) :
```
OSError(128,)
gaierror(-2, 'Name or service not known')
```
Sample Code :
```python
import wifi
import adafruit_minimqtt.adafruit_minimqtt as MQTT
radio = wifi.radio
pool = adafruit_connection_manager.get_radio_socketpool(radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(radio)
mqtt = MQTT.MQTT(
broker=...,
port=...,
is_ssl=True,
socket_pool=pool,
ssl_context=ssl_context,
username=...,
password=...,
)
try:
mqtt.publish(topic, message)
except:
mqtt.reconnect()
```
Are there any additional debugging steps that we can try out or are there other things we should consider when upgrading to CP9? Thank you!
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the sample MQTT.MQTT publish/reconnect flow on an ESP32-S3 with CircuitPython 9.0.3 and compare it with CircuitPython 8, using the listed bundle dates and recording which errors occur. Check the interactions among adafruit_minimqtt, adafruit_connection_manager socket_pool/ssl_context, and the HTTP-then-MQTT sequence; done means identifying a reproducible failure or a confirmed compatibility cause.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- embedded-iot, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100