-
Notifications
You must be signed in to change notification settings - Fork 51
honor recv_timeout in _sock_exact_recv() and ping() #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
70eba85
to
149f040
Compare
149f040
to
b99707a
Compare
Added a simple test case. |
Tested on QtPy running #!/usr/bin/env python3
import ssl
import time
import wifi
import socketpool
import adafruit_minimqtt.adafruit_minimqtt as MQTT
import adafruit_logging as logging
from secrets import secrets
def main():
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logger.info(f"Connecting to wifi {secrets['SSID']}")
wifi.radio.connect(secrets["SSID"], secrets["password"], timeout=20)
logger.info(f"Connected to {secrets['SSID']}")
logger.debug(f"IP: {wifi.radio.ipv4_address}")
pool = socketpool.SocketPool(wifi.radio)
keep_alive_timeout = 16
host = "172.40.0.3"
port = 1883
mqtt_client = MQTT.MQTT(
broker=host,
port=port,
socket_pool=pool,
ssl_context=ssl.create_default_context(),
connect_retries=1,
recv_timeout=5,
keep_alive=keep_alive_timeout,
)
mqtt_client.logger = logger
logger.debug(f"connecting with keep alive = {keep_alive_timeout}")
mqtt_client.connect()
delay = 2 * keep_alive_timeout
logger.debug(f"sleeping for {delay} seconds")
time.sleep(delay)
logger.debug("pinging the server")
try:
mqtt_client.ping()
except MQTT.MMQTTException as e:
logger.error(f"ping failed: {e}")
if __name__ == "__main__":
main() the output was as follows:
On CP it works differently than with CPython - the timeout from |
Checking the code after this change for the remaining |
The change in
The current code in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vladak this now has merge conflicts. |
0eb4404
to
5814fd0
Compare
rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go ahead and get this in. Sorry for the delay.
Updating https://github.com/adafruit/Adafruit_CircuitPython_MiniMQTT to 7.8.0 from 7.7.0: > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#190 from vladak/recv_timeout_vs_keep_alive > Merge pull request adafruit/Adafruit_CircuitPython_MiniMQTT#213 from justmobilize/no-retry-on-unauthorized Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
This logical change uses
recv_timeout
as receive timeout in_sock_exact_recv()
.Casually tested with CPython using the test case supplied in the bug, more testing will follow.