Socket connect timeout - Feature request
My use case is:
MP is connected to a network where can reach the internet (upstream network) and devices in the LAN (downstream network).
Is known that downstream devices are there and sometimes many, I need to reduce the sock.connect(addr) timeout out so this blocking call does not hang the whole system too much.
So an optional timeout parameter (in msec) would be helpful.
Thank you.
settimeout for mqtt socket
Problem statement:
If there are any network issues, mqtt will block on socket non-deterministically.
In such cases, only way to come out of the blocking is to reboot using watch dog timers.
This is costly solution.
Solution:
Alternatively, developer can set the max timeout for the socket.
Upon any issue, mqtt lib will throw exception. Developer can catch it, take
right actions like, restarting the task without rebooting the whole device.
This brings determinism and gives the control to developer to choose right time for her/his use case. This fix works for async applications too.
(I plan to make whole umqtt async compatible.)
See https://github.com/tve/mqboard/tree/master/mqtt_async
Thank you for the link.
Is it going to be part of the micropython? [https://github.com/micropython/micropython-lib/tree/master/micropython]
If so, it will have higher visibility.
Actually, this is a better version: https://github.com/peterhinch/micropython-mqtt
Eventually we would like to add links from this repository to external/third-party libraries like the above, to make them easier to install, and have better visibility.
This will be a lot helpful to all those who use async. Async really shines as it gives better control to developer over threads/processes in terms of scheduling. This in turn solves many locking issues that are common in threads. in anycase, async mqtt blends nicely into all async applications.