@@ -615,7 +615,7 @@ def ping(self) -> list[int]:
615615 self ._connected ()
616616 self .logger .debug ("Sending PINGREQ" )
617617 self ._sock .send (MQTT_PINGREQ )
618- ping_timeout = self .keep_alive
618+ ping_timeout = self ._recv_timeout
619619 stamp = self .get_monotonic_time ()
620620 self ._last_msg_sent_timestamp = stamp
621621 rc , rcs = None , []
@@ -624,7 +624,9 @@ def ping(self) -> list[int]:
624624 if rc :
625625 rcs .append (rc )
626626 if self .get_monotonic_time () - stamp > ping_timeout :
627- raise MMQTTException ("PINGRESP not returned from broker." )
627+ raise MMQTTException (
628+ f"PINGRESP not returned from broker within { ping_timeout } seconds."
629+ )
628630 return rcs
629631
630632 # pylint: disable=too-many-branches, too-many-statements
@@ -1090,7 +1092,7 @@ def _sock_exact_recv(
10901092 to_read = bufsize - recv_len
10911093 if to_read < 0 :
10921094 raise MMQTTException (f"negative number of bytes to read: { to_read } " )
1093- read_timeout = timeout if timeout is not None else self .keep_alive
1095+ read_timeout = timeout if timeout is not None else self ._recv_timeout
10941096 mv = mv [recv_len :]
10951097 while to_read > 0 :
10961098 recv_len = self ._sock .recv_into (mv , to_read )
@@ -1101,7 +1103,7 @@ def _sock_exact_recv(
11011103 f"Unable to receive { to_read } bytes within { read_timeout } seconds."
11021104 )
11031105 else : # ESP32SPI Impl.
1104- # This will timeout with socket timeout (not keepalive timeout)
1106+ # This will time out with socket timeout (not receive timeout).
11051107 rc = self ._sock .recv (bufsize )
11061108 if not rc :
11071109 self .logger .debug ("_sock_exact_recv timeout" )
@@ -1111,7 +1113,7 @@ def _sock_exact_recv(
11111113 # or raise exception if wait longer than read_timeout
11121114 to_read = bufsize - len (rc )
11131115 assert to_read >= 0
1114- read_timeout = self .keep_alive
1116+ read_timeout = self ._recv_timeout
11151117 while to_read > 0 :
11161118 recv = self ._sock .recv (to_read )
11171119 to_read -= len (recv )
0 commit comments