diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index db1270d4..43bc291a 100644 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -2174,6 +2174,8 @@ def loop_misc(self) -> MQTTErrorCode: return MQTTErrorCode.MQTT_ERR_SUCCESS + + def max_inflight_messages_set(self, inflight: int) -> None: """Set the maximum number of messages with QoS>0 that can be part way through their network flow at once. Defaults to 20.""" @@ -3274,7 +3276,7 @@ def _check_keepalive(self) -> None: last_msg_in = self._last_msg_in if self._sock is not None and (now - last_msg_out >= self._keepalive or now - last_msg_in >= self._keepalive): - if self._state == _ConnectionState.MQTT_CS_CONNECTED and self._ping_t == 0: + if self._state == _ConnectionState.MQTT_CS_CONNECTED and (self._ping_t == 0 or now - last_msg_in < self.keepalive): try: self._send_pingreq() except Exception: