micropython-lib icon indicating copy to clipboard operation
micropython-lib copied to clipboard

settimeout for mqtt socket

Open prabhu-yu opened this issue 1 year ago • 3 comments

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.)

prabhu-yu avatar Jul 03 '24 17:07 prabhu-yu

I plan to make whole umqtt async compatible.

See https://github.com/tve/mqboard/tree/master/mqtt_async

dpgeorge avatar Oct 18 '24 00:10 dpgeorge

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.

prabhu-yu avatar Oct 20 '24 06:10 prabhu-yu

Thank you for the link. Is it going to be part of the micropython?

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.

dpgeorge avatar Oct 21 '24 05:10 dpgeorge

I plan to make whole umqtt async compatible.

See https://github.com/tve/mqboard/tree/master/mqtt_async

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.

prabhu-yu avatar Nov 01 '24 15:11 prabhu-yu