coreyjs / nhl-api-py

NHL API (2024 Updated) - For accessing most of the NHL EDGE statistical API's, scores, schedules and more
GNU General Public License v3.0
26 stars 6 forks source link

Increase timeout and allow for no SSL verification #43

Closed falkyre closed 8 months ago

falkyre commented 8 months ago

The httpx library that you are using is showing a couple of issues when we are using it in our project for our next version(https://github.com/riffnshred/nhl-led-scoreboard)

We are seeing a timeout:

File "/usr/local/lib/python3.9/dist-packages/httpx/_transports/default.py", line 79, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ReadTimeout: The read operation timed out

And an issue with SSL Verification (I believe this is likely because the Cloudflare Load Balancer that the NHL is using was returning a bad cert) File "/usr/local/lib/python3.9/dist-packages/httpx/_transports/default.py", line 79, in map_httpcore_exceptions raise mapped_exc(message) from exc httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'api-web.nhle.com'. (_ssl.c:1123)

With the httpx API you do have the ability to increase the time out and also disable SSL Verification. Would it be possible to add these as options to the NHLClient like you do with verbose logging?

https://www.python-httpx.org/advanced/#timeout-configuration

https://www.python-httpx.org/advanced/#ssl-certificates

I realize that turning off the SSL Verification is considered a bad idea but it is causing our scoreboard to crash. Having the option to allow a user to bypass the verification is a good option (as long as they understand the potential risk of doing this)

coreyjs commented 8 months ago

Sure I can work on this.

coreyjs commented 8 months ago

@falkyre Do you remember which endpoint was causing this ssl issue? I wanted to see if I could replicate it to confirm a fix.

falkyre commented 8 months ago

I'll check with the user who reported it in our discord and get you that info once he comes back to me

falkyre commented 8 months ago

Looks like line 39 in the standings.py.

File "/usr/local/lib/python3.9/dist-packages/nhlpy/api/standings.py", line 39, in get_standings

coreyjs commented 8 months ago

v2.4.0