Skip to content

Unable to receive events on shadow topics MQTT5 client is subscribed to. #610

Answered by sfod
sadan asked this question in Q&A
Discussion options

You must be logged in to vote

Alright, I think I found the root cause. This code block from the IotShadowClient's parent class is the answer:

        if isinstance(mqtt_connection, mqtt.Connection):
            self._mqtt_connection = mqtt_connection  # type: mqtt.Connection
        elif isinstance(mqtt_connection, mqtt5.Client):
            self._mqtt_connection = mqtt_connection.new_connection()
            self._mqtt5_client = mqtt_connection

When you use MQTT3, the first if branch just uses the connection you pass to it from your code (DeviceAgent::mqtt_client object).
When you switch to MQTT5, the second if branch executes. You can see that a new object is created there (self._mqtt_connection = mqtt_connection.n…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@sadan
Comment options

Comment options

You must be logged in to vote
1 reply
@sadan
Comment options

Answer selected by sadan
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants