Viable HTTP(s) and MQTT Libs for WiPy?
-
Hi,
I would like to use a minimalist http lib and mutt lib that supports TLS (nice to have, cert-check).
I need it to interact mostly with REST APIs.I tested urlib from Lucien2K
https://github.com/micropython/micropython-lib/tree/master/urllib.urequest
With mixed results.
A good test-bed is mockbin (http://mockbin.org) where one can create an end-point and test all libs features (e.g. HTTP headers, payload...).Using urlib against Mockbin gives a socket 411 error, I have an idea why this happens but that's perhaps the subject for another discussion ;-)
-
We've found umqtt.simple to work fine without SSL, but if you want to use MQTTS on the WiPy, then a small modification is needed, as you can find here:
https://github.com/Enabling/WiPy-LoPy/tree/master/SensorLib/mqtt
-
@gbozzi
Thanks for the initiative, we appreciate the community contributions a lot.
I'll be following your repo. I hope that you find the mqtt libraries useful.Best Regards
Roberto Marques
-
THX @Roberto
I forked the Urequests lib I mentioned in my first post, added JSON support and fixed some minor issues.
In case someone is more comfortable with requests:
-
Hello gbozzi,
I would recommend using the mqtt library form the micro python libraries
mqtt.simple:
https://github.com/micropython/micropython-lib/tree/master/umqtt.simplemqtt.robust:
https://github.com/micropython/micropython-lib/tree/master/umqtt.robustThey are both Memory efficiency and well supported by the micro python community.
There are lot of other useful libraries at the root of the repo here
For HTTPS base your work on the ssl module, for more information go to:
https://docs.pycom.io/wipy/library/ussl.html#module-ussl