adafruit / adafruit/Adafruit_CircuitPython_MiniMQTT

Type conversion errors cause a crash on connect().

Open Beginner friendly
#260 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
81
Forks
52
PR merge metrics
No merged PRs in 30d

Description

I'm using the sample code for this library found here, with no modifications: https://learn.adafruit.com/networking-in-circuitpython/networking-with-the-wifi-module but connections consistently fail with a type conversion error.

The MQTT-specific details of the sample code are:

```python
import adafruit_minimqtt.adafruit_minimqtt as MQTT

# Callback setup removed...

mqtt_client = MQTT.MQTT(
broker=os.getenv("mqtt_broker"),
port=os.getenv("mqtt_port"),
username=os.getenv("mqtt_username"),
password=os.getenv("mqtt_password"),
socket_pool=socketpool.SocketPool(wifi.radio),
ssl_context=ssl.create_default_context(),
)

print("Connecting to MQTT broker...")
mqtt_client.connect()
```

When this code runs, there's a `TypeError` that crashes the script:

```
Traceback (most recent call last):
File "", line 67, in
File "adafruit_minimqtt/adafruit_minimqtt.py", line 448, in connect
File "adafruit_minimqtt/adafruit_minimqtt.py", line 545, in _connect
File "adafruit_connection_manager.py", line 328, in get_socket
TypeError: can't convert str to int
```

For what it's worth my `settings.toml` looks like this:

```
mqtt_broker = 192.168.1.169
mqtt_port = 1883
mqtt_user = "mqttuser"
mqtt_password = ""
```

Mosquitto is running at the broker address above with matching credentials.

I'm using the most recent version of this library (from `adafruit-circuitpython-bundle-10.x-mpy-20260724`), on a Raspberry Pi Pico 2 W.

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure with the sample configuration, then start at connect() and _connect() in adafruit_minimqtt/adafruit_minimqtt.py. Follow the traceback into get_socket() in adafruit_connection_manager.py and compare the values passed from settings.toml. Done means the shown MQTT configuration no longer crashes during connect().

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.