You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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).
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.
The text was updated successfully, but these errors were encountered: