Skip to content
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

"RuntimeError: Sending request failed" for https URL #114

Open
izuk opened this issue Aug 6, 2022 · 3 comments
Open

"RuntimeError: Sending request failed" for https URL #114

izuk opened this issue Aug 6, 2022 · 3 comments

Comments

@izuk
Copy link

izuk commented Aug 6, 2022

Getting the above error:

Adafruit CircuitPython 7.3.2 on 2022-07-20; Adafruit QT Py ESP32S2 with ESP32S2
[...]

>>> adafruit_requests.__version__
'1.12.4'

>>> response = requests.get("https://www.flightstats.com")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "adafruit_requests.py", line 726, in get
  File "adafruit_requests.py", line 667, in request
  File "adafruit_requests.py", line 518, in _get_socket
RuntimeError: Sending request failed

I've seen this reported a few times, but I'm still not clear on which library, exactly, is failing and where to look for an update that fixes it.

Here's what curl -v reports for flightstats.com:

* Connected to www.flightstats.com (54.208.3.224) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [64 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [3388 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [300 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [37 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=flightstats.com; O=LNRS Data Services Ltd; L=Sutton; ST=Surrey; C=GB
*  start date: Jun 14 07:10:36 2022 GMT
*  expire date: Jun 14 07:09:36 2023 GMT
*  subjectAltName: host "www.flightstats.com" matched cert's "www.flightstats.com"
*  issuer: C=US; ST=Illinois; L=Chicago; O=Trustwave Holdings, Inc.; CN=Trustwave Organization Validation SHA256 CA, Level 1; emailAddress=ca@trustwave.com
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
} [5 bytes data]

Is the problem the size of the certificate? The encoding? I wish I knew where to look.

@tannewt
Copy link
Member

tannewt commented Aug 8, 2022

I'd suggest starting with the requests library. There are a number of excepts here that may be catching the more relevant error: https://github.com/adafruit/Adafruit_CircuitPython_Requests/blob/main/adafruit_requests.py#L521-L541

@anecdata
Copy link
Member

Added some print statements to Requests. It's failing here with OSError: Failed SSL handshake. I'm running 7.3.3, which has the updated certificates. It's possibly an issue with TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256.

@anecdata
Copy link
Member

@izuk You may want to try the solution from:
adafruit/circuitpython#7429 (comment)

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

3 participants