diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 1c0236e4..8b39e3eb 100644 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -2945,9 +2945,10 @@ def _check_clean_session(self): def _messages_reconnect_reset_out(self): with self._out_message_mutex: self._inflight_messages = 0 + to_be_inflight = 0 for m in self._out_messages.values(): m.timestamp = 0 - if self._max_inflight_messages == 0 or self._inflight_messages < self._max_inflight_messages: + if self._max_inflight_messages == 0 or to_be_inflight < self._max_inflight_messages: if m.qos == 0: m.state = mqtt_ms_publish elif m.qos == 1: @@ -2955,6 +2956,7 @@ def _messages_reconnect_reset_out(self): if m.state == mqtt_ms_wait_for_puback: m.dup = True m.state = mqtt_ms_publish + to_be_inflight += 1 elif m.qos == 2: # self._inflight_messages = self._inflight_messages + 1 if self._check_clean_session(): @@ -2968,6 +2970,7 @@ def _messages_reconnect_reset_out(self): if m.state == mqtt_ms_wait_for_pubrec: m.dup = True m.state = mqtt_ms_publish + to_be_inflight += 1 else: m.state = mqtt_ms_queued