I am totally desperate, as I cannot connect in CircuitPython with the MiniMQTT Library to HiveMQ.
My code looks like this
import ssl
import wifi
import socketpool
import adafruit_minimqtt.adafruit_minimqtt as MQTT
# WLAN-Configuration
WLAN_SSID = "mySSID" #
WLAN_PASSWORD = "mypassword" #
# WLAN Connection
print("Connect with %s"%WLAN_SSID)
wifi.radio.connect(WLAN_SSID, WLAN_PASSWORD)
print("Connected with %s!"%WLAN_SSID)
print("My IP-Adress is", wifi.radio.ipv4_address)
# MQTT-Broker-Data
MQTT_HOST = "URL"
MQTT_PORT = 8883
MQTT_USER = "username"
MQTT_PASSWORD = "password"
# Create SSL-Context
socket_pool = socketpool.SocketPool(wifi.radio)
ssl_context = ssl.create_default_context()
# Create MQTT-Client
mqtt_client = MQTT.MQTT(broker=MQTT_HOST, port=MQTT_PORT, username=MQTT_USER, password=MQTT_PASSWORD, socket_pool=socket_pool, ssl_context=ssl_context)
# Connect to MQTT
try:
mqtt_client.connect()
print("Connected to HiveMQ Cloud!")
except Exception as e:
print("Connection Error:", e)
It returns: “Connection Error: (‘Repeated connect failures’, None)”
My device (XIAO ESP32C3) properly connects to Wifi. On another client (notebook) within the same Wifi network, I tried to connect to HiveMQ with the Paho library with Python and it all works properly (so most likely no typo in URL, username, password, no port issue).
AI did not provide any solutions - any ideas what could be wrong? Support is very much appreciated!