swar / nba_api

An API Client package to access the APIs for NBA.com
MIT License
2.5k stars 534 forks source link

Problems calling an API endpoint from a file on an EC2 instance #101

Closed ChaseAustin closed 4 years ago

ChaseAustin commented 4 years ago

I have a file where I call the CommonPlayerInfo endpoint and I store the data in a database. It works by calling the static player function to get the player ids needed for the common info requests. I wanted to run this file from an ec2 instance because it will take a long time to get information for every player. Locally, when I run my file, it works correctly. When I run it on my EC2 instance, on the line where I call:

player_info = commonplayerinfo.CommonPlayerInfo(player_id=person, headers=headers, timeout=20)

I get a timeout exception:

requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='stats.nba.com', port=443, timeout=20)

I opened my security groups to all inbound and outbound traffic, but I'm not sure why this is still happening. The static player and team information functions work locally and on my EC2 instance.

I would appreciate any help in understanding why I can't call the API from an EC2 instance.

swar commented 4 years ago

@ChaseAustin

Can you try to connect directly to the EC2 instance and see if a curl works?

I am very confident that AWS's IPs are completely blacklisted.

ChaseAustin commented 4 years ago

I tried to run curl google.com and it worked. Do you know if there is any hosting service, DigitalOcean, azure, etc. that doesn't have their IP's blacklisted?

swar commented 4 years ago

What about a curl with the stats page? You'll need to make sure the headers line up as well.

Unfortunately, I do not know as I test everything out in my local computer. Your best bet would be to get a working proxy provider to help you connect.

ChaseAustin commented 4 years ago

Thanks, you pointed me in the right direction

benschneid commented 4 years ago

Hi Chase, how did you solve this problem?

charlielogan commented 4 years ago

Has anyone solved this issue or found a workaround?

PhilDakin commented 1 year ago

Easy workaround - use https://iproyal.com/ proxy.