Closed
Description
CircuitPython version
Most recent 9.0.0 build
Code/REPL
import os
import ssl
import time
import board
import socketpool
import wifi
import adafruit_requests
print("------------------------------")
print(os.uname())
ssid = os.getenv("CIRCUITPY_WIFI_SSID")
password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
print("Connecting to WiFi...")
while not wifi.radio.connected:
wifi.radio.connect(ssid, password)
pool = socketpool.SocketPool(wifi.radio)
ssl_context = ssl.create_default_context()
requests = adafruit_requests.Session(pool, ssl_context)
urls = [
"http://wifitest.adafruit.com/testwifi/index.html",
"http://www.adafruit.com/api/quotes.php",
"https://api.github.com",
]
import time
s = time.monotonic()
try:
for url in urls:
print(url)
r = requests.get(url, timeout=300)
r.close()
except Exception as e:
print(e)
e = time.monotonic()
print(f"Time: {e-s} seconds")
print("Done!")
Behavior
Added some print statements to adafruit_requests
:
------------------------------
(sysname='ESP32S3', nodename='ESP32S3', release='9.0.0', version='9.0.0-beta.0-26-gc6d195a39f on 2024-02-12', machine='FeatherS3 with ESP32S3')
Connecting to WiFi...
http://wifitest.adafruit.com/testwifi/index.html
_get_socket: start
_get_socket: try: 1
_get_socket: set timeout: 300
http://www.adafruit.com/api/quotes.php
_get_socket: start
_get_socket: try: 1
_get_socket: set timeout: 300
_get_socket: start
_get_socket: try: 1
_get_socket: set timeout: 300
https://api.github.com
_get_socket: start
_get_socket: try: 1
_get_socket: set timeout: 300
_get_socket: socket.connect - OSError: Failed SSL handshake
_get_socket: try: 2
_get_socket: _free_sockets
_get_socket: set timeout: 300
_get_socket: socket.connect - OSError: Failed SSL handshake
_get_socket: try: 3
Sending request failed
Time: 25.471 seconds
Done!
Code done running.
Description
On a ESP32S3 chip will fail with OSError: Failed SSL handshake
when trying to socket.connect
to api.github.com
8.2.9
: works every time. Average time ~5 seconds
9.0.0-alpha.2.uf2
: happens half the time: Average time ~15 seconds
9.0.0-alpha.4.uf2
: MemoryError: memory allocation failed, allocating 1784 bytes
on line 7
9.0.0-alpha.5.uf2
: never errored: Average time ~12 seconds
9.0.0-alpha.6.uf2
: always errored: Average time ~20 seconds
9.0.0-beta.0
: always errored: Average time ~20 seconds
9.0.0-beta.0 from PR merge 8898
: always errored: Average time ~20 seconds
Additional information
No response