@@ -615,7 +615,7 @@ def ping(self) -> list[int]:
615
615
self ._connected ()
616
616
self .logger .debug ("Sending PINGREQ" )
617
617
self ._sock .send (MQTT_PINGREQ )
618
- ping_timeout = self .keep_alive
618
+ ping_timeout = self ._recv_timeout
619
619
stamp = self .get_monotonic_time ()
620
620
self ._last_msg_sent_timestamp = stamp
621
621
rc , rcs = None , []
@@ -624,7 +624,9 @@ def ping(self) -> list[int]:
624
624
if rc :
625
625
rcs .append (rc )
626
626
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
+ )
628
630
return rcs
629
631
630
632
# pylint: disable=too-many-branches, too-many-statements
@@ -1090,7 +1092,7 @@ def _sock_exact_recv(
1090
1092
to_read = bufsize - recv_len
1091
1093
if to_read < 0 :
1092
1094
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
1094
1096
mv = mv [recv_len :]
1095
1097
while to_read > 0 :
1096
1098
recv_len = self ._sock .recv_into (mv , to_read )
@@ -1101,7 +1103,7 @@ def _sock_exact_recv(
1101
1103
f"Unable to receive { to_read } bytes within { read_timeout } seconds."
1102
1104
)
1103
1105
else : # ESP32SPI Impl.
1104
- # This will timeout with socket timeout (not keepalive timeout)
1106
+ # This will time out with socket timeout (not receive timeout).
1105
1107
rc = self ._sock .recv (bufsize )
1106
1108
if not rc :
1107
1109
self .logger .debug ("_sock_exact_recv timeout" )
@@ -1111,7 +1113,7 @@ def _sock_exact_recv(
1111
1113
# or raise exception if wait longer than read_timeout
1112
1114
to_read = bufsize - len (rc )
1113
1115
assert to_read >= 0
1114
- read_timeout = self .keep_alive
1116
+ read_timeout = self ._recv_timeout
1115
1117
while to_read > 0 :
1116
1118
recv = self ._sock .recv (to_read )
1117
1119
to_read -= len (recv )
0 commit comments