diff --git a/azure-iot-device/azure/iot/device/common/mqtt_transport.py b/azure-iot-device/azure/iot/device/common/mqtt_transport.py index cf54a0416..200f0570c 100644 --- a/azure-iot-device/azure/iot/device/common/mqtt_transport.py +++ b/azure-iot-device/azure/iot/device/common/mqtt_transport.py @@ -190,6 +190,10 @@ def on_connect(client, userdata, flags, rc): logger.warning( "connection failed, but no on_mqtt_connection_failure_handler handler callback provided" ) + elif not this: + logger.info( + "on_connect called with transport==None. Transport must have been garbage collected. stopping loop" + ) elif this.on_mqtt_connected_handler: try: this.on_mqtt_connected_handler()