Page 1 of 1

Thread safe https post

Posted: Wed Jun 01, 2022 10:18 am
by Cosystick
Hello fellow Hardware-tinkerers!
I am using asyncio.start_server to serve html for monitoring a thermometer and to administer temp triggers and notification settings.
I have a Wemos D1 Mini (esp8266) board.

Serving the html works, reading the thermometer using onewire works, saving settings to local storage works.

When I use asyncio to do a asyncio.post to the pushbullet api, using HTTPS.
I can't seem to get anything but no response or 400 Bad Request. I have seen some mentioning of asyncio not working with SSL, but then some where the author says it's working.

I have tried using a version of arequest.py I found while googling, urequest is blocking and isn't working, I have tried using a "lib" called http_client and I have tried all manner of other different libs.

I can't seem to find any that doesn't end up with a bad request or none response.

What I want to do, is an async post, with headers and json body to https.

Does anyone have any ideas? Does anyone have the source code to the latest version of arequest.py?

Re: Thread safe https post

Posted: Thu Jun 02, 2022 5:34 am
by KJM
I'm not familiar with arequest.py but urequests can do headers+json if suitably primed https://stackoverflow.com/questions/624 ... n-language

Re thread safe usage. I too read a lot of stuff about asyncio/ssl compatibility. I ended up calling urequests from a timed out def as a separate thread. If the urequests thread stalls the calling def times out & the main program is free to continue after the timeout.