Skip to content

Publish doesn't wait when QOS1 #324

@YannickRiou

Description

@YannickRiou

Describe the bug

The publish function isn't pushing data to AWS after connection is recovered

Name: awscrt
Version: 0.5.13
Home-page: https://github.com/awslabs/aws-crt-python

Name: AWSIoTPythonSDK
Version: 1.4.7
Home-page: https://github.com/aws/aws-iot-device-sdk-python.git

Name: awsiotsdk
Version: 1.0.6
Home-page: https://github.com/aws/aws-iot-device-sdk-python-v2

Expected Behavior

When connection is lost, and a publish (with QOS1) was done and not successful, it should try to resend the message automatically (as QOS1 statement).

Current Behavior

When connection is lost, the publish send back a state pending about the data to be sent, but then when the device shutdown, the message hasn't been send at all.

Reproduction Steps

Connect with :

        event_loop_group = io.EventLoopGroup(1)
        host_resolver = io.DefaultHostResolver(event_loop_group)
        client_bootstrap = io.ClientBootstrap(event_loop_group, host_resolver)

        self.mqtt_connection = mqtt_connection_builder.mtls_from_path(
            endpoint=self.iot_endpoint,
            cert_filepath=self.cert_filepath,
            pri_key_filepath=self.pri_key_filepath,
            client_bootstrap=client_bootstrap,
            ca_filepath=self.ca_filepath,
            on_connection_interrupted=self.on_connection_interrupted,
            on_connection_resumed=self.on_connection_resumed,
            client_id=self.client_id,
            clean_session=False,
            keep_alive_secs=30
        )

        logging.debug(" Connecting to {} with client ID '{}'...".format(self.iot_endpoint, self.client_id))
        
        connect_future = self.mqtt_connection.connect()

   # Future.result() waits until a result is available
        try:
            connect_future.result()        
            logging.debug(" Connected!")
        except Exception as e:
            print(e)
            return False

Publish with :

  logging.debug(" Publishing message to topic '{}': {}".format(topic, message))
        ret = self.mqtt_connection.publish(
            topic=topic,
            payload=message,
            qos=mqtt.QoS.AT_LEAST_ONCE)
        logging.debug(" Value returned by publish is ['{}']".format(str(ret)))

Possible Solution

The loop handling the resend of message (due to QOS1) is not working properly

Additional Information/Context

No response

SDK version used

1.0.6

Environment details (OS name and version, etc.)

Raspberry pi Zero - Raspbian Buster - Linux - 5.10.52+ #1440

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessresponse-requestedWaiting on additional info and feedback. Will move to "closing-soon" in 2 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions