From 9828a468b66d3818898dd75f80927d3466e15192 Mon Sep 17 00:00:00 2001 From: neelinfocusp Date: Tue, 20 Jan 2026 14:23:37 +0530 Subject: [PATCH 1/2] Added logic to update last_msg_out timestamp once packet is sent successfully --- src/paho/mqtt/client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 4ccc8696..90315361 100644 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -3238,6 +3238,10 @@ def _packet_write(self) -> MQTTErrorCode: else: # We haven't finished with this packet self._out_packet.appendleft(packet) + + # Update the last message out time once packet (partial packet) is sent + with self._msgtime_mutex: + self._last_msg_out = time_func() else: break From 7ba2238f200f74bb5a79d3eae1ea54edb3ff06f8 Mon Sep 17 00:00:00 2001 From: neelinfocusp Date: Tue, 20 Jan 2026 16:15:01 +0530 Subject: [PATCH 2/2] re-ordered last_msg_out timestamp update logic --- src/paho/mqtt/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 90315361..58ce2b15 100644 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -3180,6 +3180,10 @@ def _packet_write(self) -> MQTTErrorCode: return MQTTErrorCode.MQTT_ERR_CONN_LOST if write_length > 0: + # Update the last message out time once packet (partial packet) is sent + with self._msgtime_mutex: + self._last_msg_out = time_func() + packet['to_process'] -= write_length packet['pos'] += write_length @@ -3238,10 +3242,6 @@ def _packet_write(self) -> MQTTErrorCode: else: # We haven't finished with this packet self._out_packet.appendleft(packet) - - # Update the last message out time once packet (partial packet) is sent - with self._msgtime_mutex: - self._last_msg_out = time_func() else: break