Skip to content

Inevitable socket timeouts using time.monotonic() #152

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

Closed
ktritz opened this issue Mar 16, 2024 · 0 comments · Fixed by #156
Closed

Inevitable socket timeouts using time.monotonic() #152

ktritz opened this issue Mar 16, 2024 · 0 comments · Fixed by #156

Comments

@ktritz
Copy link

ktritz commented Mar 16, 2024

time.monotonic in adafruit_wiznet5k_socket.py loses more and more precision the longer the uptime of the board, so if the board is in service for hours/days/weeks, depending on the timeout set, eventually the precision of the monotonic call will be coarser than the timeout setting. This will cause a spurious timeout when you happen to catch the coarse 'tick' of the monotonic clock for the timeout comparison.

I've seen this happen using wiznet5k with mqtt after a couple of days of uptime while using a socket timeout of 0.1s. A hard microcontroller reset will fix this, and longer socket timeout values should extend the uptime, but this isn't a good solution for a high uptime use case.

Likely shifting to monotonic_ns, or adafruit_ticks will solve this, but it will take some time to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant