Skip to content

Commit 8fbb34a

Browse files
committed
use receive timeout for ping handling as well
1 parent 913b1d4 commit 8fbb34a

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
@@ -705,15 +705,17 @@ def ping(self) -> list[int]:
705705
self._connected()
706706
self.logger.debug("Sending PINGREQ")
707707
self._sock.send(MQTT_PINGREQ)
708-
ping_timeout = self.keep_alive
708+
ping_timeout = self._recv_timeout
709709
stamp = self.get_monotonic_time()
710710
rc, rcs = None, []
711711
while rc != MQTT_PINGRESP:
712712
rc = self._wait_for_msg()
713713
if rc:
714714
rcs.append(rc)
715715
if self.get_monotonic_time() - stamp > ping_timeout:
716-
raise MMQTTException("PINGRESP not returned from broker.")
716+
raise MMQTTException(
717+
f"PINGRESP not returned from broker within {ping_timeout} seconds."
718+
)
717719
return rcs
718720

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

0 commit comments

Comments
 (0)