Skip to content

_thread Issue with HTTPS #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Skipper-is opened this issue Sep 15, 2019 · 1 comment
Open

_thread Issue with HTTPS #351

Skipper-is opened this issue Sep 15, 2019 · 1 comment

Comments

@Skipper-is
Copy link

Skipper-is commented Sep 15, 2019

I've been using _thread to run a background task, and at one point the background task posts some data online (so, connects to the wifi, HTTP request and print the result). First time it works well, but whenever I repeat it, I tend to get a number of errors, the main one being
mbedtls_ssl_handshake error: -4290
and
File "urequests.py", line 111, in post File "urequests.py", line 96, in request File "urequests.py", line 60, in request OSError: [Errno 5] EIO
I assume this has something to do with the thread trying to access the wifi twice, as it works the first time, every time, but 2nd time around, no joy.
I have tried wlan.disconnect(), and wlan.active(False) to disable the wifi in between requests, but without much joy.

This is my function:
def postJSON(j, url, retries=0, max_retries=4): data = ujson.dumps(j) if retries < max_retries: # Only retry the connection 3 times, otherwise, give up TODO: Don't give up silently! wlan = network.WLAN(network.STA_IF) if wlan.isconnected(): # Check connection print(data) r = requests.post(url=url, json=j, headers={"Authorization": "Basic " + authkey}) if (r.status_code == 200): # Check if the response OK print("success") wlan.disconnect() return True else: # Otherwise, retry postJSON(j, url, retries+1) else: do_connect() postJSON(j, url, retries+1) else: print("Tried 4 times, and failed. Sorry\r\nGiving Up") return False

Running this on the main thread throws up no such issues.

@dpgeorge
Copy link
Member

This sounds like an issue for the core firmware at https://github.com/micropython/micropython . When posting an issue there you should state the port you use (eg esp32?), the version of MicroPython, and fully reproducible code (where possible).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants