Skip to content

Conversation

jepler
Copy link

@jepler jepler commented May 21, 2024

The cause was that setting the __cause__ property on an exception didn't set the built in exception object's cause property, so it's necessary to fetch the property from the actual object when needed.

@justmobilize
Copy link

Tested on a UM FeatherS3:

This code will fail, since the MQTT server isn't connecting vis SSL, but on a SSL port:

import adafruit_connection_manager
import wifi
esp = wifi.radio
pool = adafruit_connection_manager.get_radio_socketpool(esp)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(esp)
import adafruit_minimqtt.adafruit_minimqtt as MQTT
mqtt_client = MQTT.MQTT(
     broker="io.adafruit.com",
     username="ADAFRUIT_AIO_USERNAME",
     password="ADAFRUIT_AIO_KEY",
     port=8883,
     socket_timeout=1,
     recv_timeout=2,
     socket_pool=pool,
     ssl_context=ssl_context,
     is_ssl=False,
)
mqtt_client.connect()

Result:

Traceback (most recent call last):
  File "adafruit_minimqtt/adafruit_minimqtt.py", line 429, in connect
  File "adafruit_minimqtt/adafruit_minimqtt.py", line 567, in _connect
Exception: ('No data received from broker for 2 seconds.', None)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_minimqtt/adafruit_minimqtt.py", line 458, in connect
MMQTTException: ('Repeated connect failures', None)

@dhalbert
Copy link
Collaborator

@justmobilize so are you saying it works for you? Not sure :)

@justmobilize
Copy link

@dhalbert , yes I now see both exceptions. This works perfectly

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants