tejado / pgoapi

Pokemon Go API lib
Other
1.4k stars 445 forks source link

Add timeout to API call #78

Closed nborrmann closed 6 years ago

nborrmann commented 8 years ago

When logging in, the niantic server sometimes doesn't respond at all. Which will cause any tool using this API to hang forever (my server hung overnight for hours). The requests library by default has not timeout value, so we need to set it manually.

nborrmann commented 8 years ago

The following error message appeared after this fix when logging in (line 54):

ConnectionError: HTTPSConnectionPool(host='sso.pokemon.com', port=443): Max retries exceeded with url: /sso/login?service=https%3A%2F%2Fsso.pokemon.com%2Fsso%2Foauth2.0%2FcallbackAuthorize (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x0000000003918E10>: Failed to establish a new connection: [Errno 11004] getaddrinfo failed',))

Note that I purposefully didn't add an except statement for this, as the user must take action after this occured (wait for a few minutes). Maybe we should document this? Or maybe raise our own exception?

colinchilds commented 8 years ago

+1 would love to see this added

tejado commented 8 years ago

Thanks a lot :) I will check for this tomorrow!

tejado commented 8 years ago

Can you adjsut the PR please?

FilipiMor commented 8 years ago

I really hope this go to Master, I fixed my servers using his code, and seems to be working. Thank you.

tejado commented 8 years ago

@nborrmann Last chance, otherwise I will do it :D