M
Just want to share actual working sample.
NOTE: Checking server certificate is DISABLED in this case.
You need CERT_REQUIRED or CERT_REQUIRED judging from documentation.
But, by some reason in my build ussl.CERT_REQUIRED gave "...object has no attribute...".
# ---------------------------------------------
# Tested setup:
# - Traefik Proxy 2.5 (Let's Encrypt Cert)
# - Mosquitto 2.0.16
# - MicroPython 1.17
# ----------------------------------------------
from umqtt.simple import MQTTClient
HOST = "<HOST>"
# Without server_hostname it wan't connect (by some reason)
ssl_params = {"server_hostname": HOST}
c = MQTTClient("<client_id>",
server=HOST,
port=8883,
user="<username>",
password="<password>",
# Need keepalive > 0 or got MqttException(2)
keepalive=10,
ssl=True,
ssl_params=ssl_params)