Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Callback in publishAsync not triggered for messages drained after a disconnection #226

Closed
@Ettore-P

Description

@Ettore-P

I noticed that when the connection is lost, if i perform a publishAsync the messages are correctly queued, and when the connection is re-established the messages are drained, but during the draining process the callback is not called. It looks like the draining process is performed with sync publish. It doesn't look like a bug in the code, is this the expected behaviour or it's an oversight?
If it's the expected behaviour i think would be better to point it out in the documentation because can lead to unexpected errors in an implementation that expects that the callback would be called after every message is correctly sent (even after a disconnection/reconnection). Also, if it's the expected behaviour, why? Is there a reason why the callback can't be queued?

...
2019-10-15 17:25:19,193 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async publish...
2019-10-15 17:25:19,195 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2019-10-15 17:25:19,231 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2019-10-15 17:25:19,234 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2019-10-15 17:25:19,236 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2019-10-15 17:25:19,239 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
-->completed the last online asyncPublish with his callback
2019-10-15 17:26:19,278 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async publish...
2019-10-15 17:26:19,281 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
-->async publish stopped by disconnection
2019-10-15 17:26:19,284 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [disconnect] event
2019-10-15 17:26:19,285 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [disconnect] event
2019-10-15 17:26:19,287 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2019-10-15 17:26:19,288 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [disconnect] event
2019-10-15 17:26:19,289 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [disconnect] event
2019-10-15 17:26:19,290 - AWSIoTPythonSDK.core.protocol.connection.cores - DEBUG - backOff: current backoff time is: 15 sec.
2019-10-15 17:26:19,291 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2019-10-15 17:26:54,312 - AWSIoTPythonSDK.core.protocol.connection.cores - DEBUG - backOff: current backoff time is: 30 sec.
2019-10-15 17:27:19,340 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async publish...
2019-10-15 17:27:19,341 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Offline request detected!
2019-10-15 17:27:19,342 - AWSIoTPythonSDK.core.protocol.internal.queues - DEBUG - append: Add new element: <AWSIoTPythonSDK.core.protocol.internal.requests.QueueableRequest object at 0x760c9750>
-->starts queuing messages
2019-10-15 17:27:44,354 - AWSIoTPythonSDK.core.protocol.connection.cores - DEBUG - backOff: current backoff time is: 60 sec.
2019-10-15 17:28:19,425 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async publish...
2019-10-15 17:28:19,426 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Offline request detected!
2019-10-15 17:28:19,427 - AWSIoTPythonSDK.core.protocol.internal.queues - DEBUG - append: Add new element: <AWSIoTPythonSDK.core.protocol.internal.requests.QueueableRequest object at 0x7688c9b0>
2019-10-15 17:29:04,382 - AWSIoTPythonSDK.core.protocol.connection.cores - DEBUG - backOff: current backoff time is: 120 sec.
2019-10-15 17:29:19,512 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async publish...
2019-10-15 17:29:19,513 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Offline request detected!
2019-10-15 17:29:19,514 - AWSIoTPythonSDK.core.protocol.internal.queues - DEBUG - append: Add new element: <AWSIoTPythonSDK.core.protocol.internal.requests.QueueableRequest object at 0x7600a950>
2019-10-15 17:30:19,598 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async publish...
2019-10-15 17:30:19,599 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Offline request detected!
2019-10-15 17:30:19,600 - AWSIoTPythonSDK.core.protocol.internal.queues - DEBUG - append: Add new element: <AWSIoTPythonSDK.core.protocol.internal.requests.QueueableRequest object at 0x7600a670>
2019-10-15 17:31:04,764 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [connack] event
2019-10-15 17:31:04,764 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [connack] event
2019-10-15 17:31:04,766 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Has recovery job
2019-10-15 17:31:04,768 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Start draining
2019-10-15 17:31:04,768 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2019-10-15 17:31:04,770 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Processed offline publish request
2019-10-15 17:31:05,004 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2019-10-15 17:31:05,005 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2019-10-15 17:31:05,006 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2019-10-15 17:31:05,007 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
-->the callback of the last async publish interrupted by the disconnection i guess?
2019-10-15 17:31:05,008 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2019-10-15 17:31:05,008 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2019-10-15 17:31:05,773 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Processed offline publish request
-->not calling the custom callback anymore for the draining messages
2019-10-15 17:31:05,899 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2019-10-15 17:31:05,900 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2019-10-15 17:31:06,776 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Processed offline publish request
2019-10-15 17:31:06,851 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2019-10-15 17:31:06,852 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2019-10-15 17:31:07,781 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Processed offline publish request
2019-10-15 17:31:07,849 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2019-10-15 17:31:07,851 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2019-10-15 17:31:19,659 - AWSIoTPythonSDK.core.protocol.mqtt_core - INFO - Performing async publish...
-->restarting the online publishing without queue, all ok
2019-10-15 17:31:19,661 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Filling in custom puback (QoS>0) event callback...
2019-10-15 17:31:19,896 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Produced [puback] event
2019-10-15 17:31:19,897 - AWSIoTPythonSDK.core.protocol.internal.workers - DEBUG - Dispatching [puback] event
2019-10-15 17:31:19,897 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - Invoking custom event callback...
2019-10-15 17:31:19,899 - AWSIoTPythonSDK.core.protocol.internal.clients - DEBUG - This custom event callback is for pub/sub/unsub, removing it after invocation...
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions