Description
Confirm by changing [ ] to [x] below to ensure that it's a bug:
- I've searched for previous similar issues and didn't find any solution
Describe the bug
With large keep_alive_secs (60 seconds) When a connection is lost the publish future finishes without exception. The connection error raises immediately after that
SDK version number
1.0.6
Platform/OS/Device
Ubuntu 18.04.4 LTS
4.15.0-99-generic #100-Ubuntu SMP Wed Apr 22 20:32:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
To Reproduce (observed behavior)
Publish callback:
def done_callback(future):
print(datetime.now().strftime("%H:%M:%S.%f:"))
print("Done callback")
print(future.result())
print(future.exception())
Increase keep_alive_secs:
clean_session=False,
keep_alive_secs=60)
publish:
count = 10
print(datetime.now().strftime("%H:%M:%S.%f:"))
print("Sending {} message(s)".format(count))
publish_count = 1
while (publish_count <= count) or (count == 0):
print(datetime.now().strftime("%H:%M:%S.%f:"))
print("Publishing message to topic '{}': {}".format(
topic, message))
pub_future, _ = mqtt_connection.publish(
topic=topic,
payload=message,
qos=mqtt.QoS.AT_LEAST_ONCE)
publish_count += 1
pub_future.add_done_callback(done_callback)
time.sleep(10)
time.sleep(10)
After the first publish occurs, try disconnecting the network. All publish callbacks are called right before the timeout error, but no clue is given that the publish actually failed.
Expected behavior
All callbacks from messages that have not been acknowledged before the timeout should have an exception
Logs/output
13:42:10.285837:
Connecting
13:42:10.999531:
Connected!
13:42:10.999735:
Sending 10 message(s)
13:42:10.999868:
Publishing message to topic 'alarms/202003_01_test': {"test": 1} [1]
13:42:11.100984:
Done callback
{'packet_id': 1}
None
13:42:21.000566:
Publishing message to topic 'alarms/202003_01_test': {"test": 1} [2]
13:42:31.009611:
Publishing message to topic 'alarms/202003_01_test': {"test": 1} [3]
13:42:41.014124:
Publishing message to topic 'alarms/202003_01_test': {"test": 1} [4]
13:42:51.024614:
Publishing message to topic 'alarms/202003_01_test': {"test": 1} [5]
13:43:01.034636:
Publishing message to topic 'alarms/202003_01_test': {"test": 1} [6]
13:43:11.038801:
Publishing message to topic 'alarms/202003_01_test': {"test": 1} [7]
13:43:14.000900:
Done callback
{'packet_id': 3}
None
13:43:14.001277:
Done callback
{'packet_id': 7}
None
13:43:14.001432:
Done callback
{'packet_id': 1}
None
13:43:14.001540:
Done callback
{'packet_id': 4}
None
13:43:14.001641:
Done callback
{'packet_id': 2}
None
13:43:14.001742:
Done callback
{'packet_id': 5}
None
13:43:14.001970:
Connection interrupted. error: AwsCrtError(name='AWS_ERROR_MQTT_TIMEOUT', message='Time limit between request and response has been exceeded.', code=5129)