Skip to content

Commit 913d275

Browse files
committed
use receive timeout for ping handling as well
1 parent 71f9f9d commit 913d275

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def ping(self) -> list[int]:
593593
self._connected()
594594
self.logger.debug("Sending PINGREQ")
595595
self._sock.send(MQTT_PINGREQ)
596-
ping_timeout = self.keep_alive
596+
ping_timeout = self._recv_timeout
597597
stamp = self.get_monotonic_time()
598598
self._last_msg_sent_timestamp = stamp
599599
rc, rcs = None, []
@@ -602,7 +602,9 @@ def ping(self) -> list[int]:
602602
if rc:
603603
rcs.append(rc)
604604
if self.get_monotonic_time() - stamp > ping_timeout:
605-
raise MMQTTException("PINGRESP not returned from broker.")
605+
raise MMQTTException(
606+
f"PINGRESP not returned from broker within {ping_timeout} seconds."
607+
)
606608
return rcs
607609

608610
# pylint: disable=too-many-branches, too-many-statements

0 commit comments

Comments
 (0)