A "resilient" asynchronous MQTT client
Posted: Mon Jul 24, 2017 10:59 am
An attempt to provide asynchronous operation and supply improved operation in the presence of unreliable WiFi, such as in the presence of interference or near the limit of range. It also offers true qos == 1 operation with duplicate message publication.
The official "robust" MQTT client is commendably lightweight but has the following limitations:
Testing proved difficult because of the number of possible failure modes, however in my testing it is reliable and improves the usable range. If anyone fancies testing it on an ESP32 I'd be keen to hear the results; also with SSL/TLS which I've been unable to test.
[EDIT]
The URL:https://github.com/peterhinch/micropython-mqtt.git
The official "robust" MQTT client is commendably lightweight but has the following limitations:
- It uses blocking sockets which can cause execution to pause for arbitrary periods when accessing a slow broker. It can also block forever in the case of qos == 1 publications while it waits for a publication acknowledge which never arrives; this can occur if a WiFi outage occurs at this point in the sequence. This blocking behaviour limits compatibility with asynchronous applications.
- It is unable reliably to resume operation after a WiFi outage.
- Its support for qos == 1 is partial. It does not support retransmission in the event of a publication acknowledge being lost. This can occur on a WiFi network especially near the limit of range or in the presence of interference.
- Its partial qos == 1 support and inability reliably to resume after a WiFi outage places a limit on the usable WiFi range. To achieve reliable operation the client must be well within range of the access point (AP).
Testing proved difficult because of the number of possible failure modes, however in my testing it is reliable and improves the usable range. If anyone fancies testing it on an ESP32 I'd be keen to hear the results; also with SSL/TLS which I've been unable to test.
[EDIT]
The URL:https://github.com/peterhinch/micropython-mqtt.git