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

Connection Error #94

Closed
brettak09 opened this issue Nov 7, 2019 · 17 comments
Closed

Connection Error #94

brettak09 opened this issue Nov 7, 2019 · 17 comments
Labels
bug Something isn't working question Inquiry from community

Comments

@brettak09
Copy link

Unable to connect and receiving the error message below.

ReadTimeout: HTTPSConnectionPool(host='stats.nba.com', port=443): Read timed out. (read timeout=30)

@ilakisp
Copy link

ilakisp commented Nov 7, 2019

I feel like nba website is either having issues or has been changed somehow. Though I'm not using nba_api (still with nba_py scraper), I have a similar connectivity issue that was not there yesterday :(

@andjmorrison
Copy link

Also having this problem with this package and the entirety of stats.nba.com from browser as well. I'm hoping it's a server/maintenance issue.

@davidkim2293
Copy link

I'm getting ConnectionError: ('Connection aborted.', OSError("(10054, 'WSAECONNRESET')",)) since this morning

@chisox721
Copy link

Definitely seems to be a server issue. I have scripts independent from nba_api that keep hanging. When using browser some links work while others dont which is really strange.

@andjmorrison
Copy link

andjmorrison commented Nov 7, 2019

Agreed--after fiddling around with the raw API itself (not this wrapper) I realized some endpoints were working, but the majority seem to be down? Hopefully back up soon.

@evmcheb
Copy link

evmcheb commented Nov 8, 2019

Hey guys, found a temporary workaround. I realised the endpoints would work if clicked from a browser, so trialed and errored with the headers until I came up with a fix.
Set the 'Referer' field in the header to 'https://github.com'.
Weird I know. Not sure if its any website - didn't test any others.

@swar
Copy link
Owner

swar commented Nov 8, 2019

@calebcheng00 is correct.

It looks like they changed up the header requirements where you now need to pass in a referrer. You guys can get this temporarily working in your code by having these headers:

headers = {
    'Host': 'stats.nba.com',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0',
    'Accept': 'application/json, text/plain, */*',
    'Accept-Language': 'en-US,en;q=0.5',
    'Referer': 'https://stats.nba.com/',
    'Accept-Encoding': 'gzip, deflate, br',
    'Connection': 'keep-alive',
}

and passing it into each of your requests as follows:

r = CommonPlayerInfo(player_id=2544, headers=headers)

@swar
Copy link
Owner

swar commented Nov 8, 2019

I am going to work on pushing out a new version this weekend. I have had bad luck these past few weeks where my computer completely crashed requiring a reformat and grad school has me very busy right now. However, this weekend looks good.

@swar swar added bug Something isn't working question Inquiry from community labels Nov 8, 2019
@swar
Copy link
Owner

swar commented Nov 10, 2019

Added updated headers as of v1.1.5.

It has been updated on PyPi as well. Go ahead and run pip install --upgrade nba_api.

Feel free to reopen this issue or create a new one if the issue persists.

@galsk87
Copy link

galsk87 commented Nov 24, 2019

I'm still getting the same error even with the update.

@swar
Copy link
Owner

swar commented Dec 19, 2019

@galsk87 Can you provide more information in a new ticket?

@MutzDude
Copy link

MutzDude commented Dec 19, 2019 via email

@skip53
Copy link

skip53 commented Jan 19, 2020

Until today, the issue had not being solved.

@drue13
Copy link

drue13 commented Jan 23, 2020

Same issue occurred today. I run this code every day. Ideas?

@kabariquaye
Copy link

kabariquaye commented Feb 2, 2020

Hi, on Mac and going through Chrome browser working in Enthought Canopy environment the following worked for me for January 19, 2020 data ....

headers = {
    'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.42 Safari/537.36',
    'x-nba-stats-origin': 'stats',
}

Full working data read-in


import requests
import pandas as pd

url = 'https://stats.nba.com/stats/leaguedashplayerstats?College=&Conference=&Country=&DateFrom=01%2F19%2F2020&DateTo=01%2F19%2F2020&Division=&DraftPick=&DraftYear=&GameScope=&GameSegment=&Height=&LastNGames=0&LeagueID=00&Location=&MeasureType=Base&Month=0&OpponentTeamID=0&Outcome=&PORound=0&PaceAdjust=N&PerMode=PerGame&Period=0&PlayerExperience=&PlayerPosition=&PlusMinus=N&Rank=N&Season=2019-20&SeasonSegment=&SeasonType=Regular+Season&ShotClockRange=&StarterBench=&TeamID=0&TwoWay=0&VsConference=&VsDivision=&Weight='

headers = {
    'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.42 Safari/537.36',
    'x-nba-stats-origin': 'stats',
}

r=requests.get(url,headers=headers)
numrecords = len(r.json()['resultSets'][0]['rowSet'])
fields=r.json()['resultSets'][0]['headers']
data = pd.DataFrame(index = np.arange(numrecords) , columns = fields)
for i in range(0,numrecords):
    records = r.json()['resultSets'][0]['rowSet'][i]
    for j in range(0,len(records)):
        data.iloc[[i],[j]]=records[j]

data 

@tipii
Copy link

tipii commented Feb 10, 2020

Updapting "User-Agent" and adding 'x-nba-stats-origin' line from @kabariquaye previous response directly into the library (in venv/lib/python3.7/site-packages/nba_api/stats/library/http.py for me) worked for me !
Thanks

@benschneid
Copy link

If you're using EC2, assigning an IPV6 address to the instance fixed it for me.

On Wed, Dec 18, 2019, 8:24 PM Swar Patel @.***> wrote: @galsk87 https://github.com/galsk87 Can you provide more information in a new ticket? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#94?email_source=notifications&email_token=AGA4C2EF5BHYV6MC6GMTFNDQZLELVA5CNFSM4JKN7JMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHIB76I#issuecomment-567287801>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGA4C2BGBSQKWX23QBHX42TQZLELVANCNFSM4JKN7JMA .

@MutzDude when you assigned an ipv6 address, did you have to change anything else in your instance? Or any parameters in your request? Still getting timeouts after assigning an ipv6 address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Inquiry from community
Projects
None yet
Development

No branches or pull requests