forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Milestone
Description
CircuitPython version
Adafruit CircuitPython 9.0.0-beta.0-32-g2e29772eb2 on 2024-02-14; FeatherS3 with ESP32S3
From:
2024-02-14T19:32:55.000Z
adafruit-circuitpython-unexpectedmaker_feathers3-en_US-20240214-no-branch-2e29772.uf2Code/REPL
# SPDX-FileCopyrightText: Copyright (c) 2024 Justin Myers
#
# SPDX-License-Identifier: Unlicense
import time
import wifi
import adafruit_connection_manager
adafruit_groups = [
{
"heading": "Common hosts",
"description": "These are common hosts users hit.",
"success": "yes",
"fail": "no",
"subdomains": [
{"host": "api.fitbit.com"},
{"host": "api.github.com"},
{"host": "api.thingspeak.com"},
{"host": "api.twitter.com"},
{"host": "discord.com"},
{"host": "id.twitch.tv"},
{"host": "oauth2.googleapis.com"},
{"host": "opensky-network.org"},
{"host": "www.adafruit.com"},
{"host": "www.googleapis.com"},
{"host": "youtube.googleapis.com"},
],
},
{
"heading": "Known problem hosts",
"description": "These are hosts we have run into problems in the past.",
"success": "yes",
"fail": "no",
"subdomains": [
{"host": "valid-isrgrootx2.letsencrypt.org"},
],
},
]
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_contexts(wifi.radio)
connection_manager = adafruit_connection_manager.get_connection_manager(pool)
def check_group(groups, group_name):
print(f"\nRunning {group_name}")
for group in groups:
print(f'\n - {group["heading"]}')
success = group["success"]
fail = group["fail"]
for subdomain in group["subdomains"]:
if "host" in subdomain:
host = subdomain["host"]
else:
host = f'{subdomain["subdomain"]}.badssl.com'
port = subdomain.get("port", 443)
exc = None
start_time = time.monotonic()
try:
socket = connection_manager.get_socket(
host, port, "https:", is_ssl=True, ssl_context=ssl_context
)
connection_manager.close_socket(socket)
except Exception as e:
exc = e
duration = time.monotonic() - start_time
if fail == "yes" and exc and "Failed SSL handshake" in str(exc):
result = "passed"
elif success == "yes" and exc is None:
result = "passed"
else:
result = f"error - success:{success}, fail:{fail}, exc:{exc}"
print(f" - {host}:{port} took {duration:.2f} seconds | {result}")
check_group(adafruit_groups, "Adafruit")Behavior
When running this on 8.2.9 on a UM FeatherS3 I get:
Running Adafruit
- Common hosts
- api.fitbit.com:443 took 0.69 seconds | passed
- api.github.com:443 took 1.43 seconds | passed
- api.thingspeak.com:443 took 1.20 seconds | passed
- api.twitter.com:443 took 0.67 seconds | passed
- discord.com:443 took 3.75 seconds | passed
- id.twitch.tv:443 took 0.55 seconds | passed
- oauth2.googleapis.com:443 took 0.87 seconds | passed
- opensky-network.org:443 took 1.64 seconds | passed
- www.adafruit.com:443 took 0.63 seconds | passed
- www.googleapis.com:443 took 1.17 seconds | passed
- youtube.googleapis.com:443 took 0.90 seconds | passed
- Known problem hosts
- valid-isrgrootx2.letsencrypt.org:443 took 1.94 seconds | passed
But on the most recent build of 9.0.0-beta.0 I get:
Running Adafruit
- Common hosts
- api.fitbit.com:443 took 0.59 seconds | passed
- api.github.com:443 took 10.37 seconds | error - success:yes, fail:no, exc:Error connecting socket: Failed SSL handshake
- api.thingspeak.com:443 took 0.97 seconds | passed
- api.twitter.com:443 took 0.66 seconds | passed
- discord.com:443 took 5.91 seconds | passed
- id.twitch.tv:443 took 3.11 seconds | passed
- oauth2.googleapis.com:443 took 3.20 seconds | passed
- opensky-network.org:443 took 1.55 seconds | passed
- www.adafruit.com:443 took 3.09 seconds | passed
- www.googleapis.com:443 took 3.21 seconds | passed
- youtube.googleapis.com:443 took 3.20 seconds | passed
- Known problem hosts
- valid-isrgrootx2.letsencrypt.org:443 took 17.97 seconds | passed
Description
In both cases I ran it a few time and grabbed the set with the lowest numbers. As you can see, some are on general par with the others, but some take on average 2-3x longer on 9.0
Additional information
No response