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

pgoapi.exceptions.UnexpectedResponseException: Unexpected HTTP server response - needs 200 got 502 #2406

Closed
JSchwerberg opened this issue Aug 2, 2016 · 3 comments

Comments

@JSchwerberg
Copy link
Contributor

JSchwerberg commented Aug 2, 2016

Expected Behavior

Bot continues to run, doesn't crash

Actual Behavior

Traceback (most recent call last):
  File "./pokecli.py", line 442, in <module>
    main()
  File "./pokecli.py", line 85, in main
    report_summary(bot)
  File "./pokecli.py", line 93, in report_summary
    metrics.capture_stats()
  File "/home/junaos/PokemonGo-Bot/pokemongo_bot/metrics.py", line 76, in capture_stats
    response_dict = request.call()
  File "/home/junaos/PokemonGo-Bot/pokemongo_bot/api_wrapper.py", line 100, in call
    result = self._call()
  File "/home/junaos/PokemonGo-Bot/pokemongo_bot/api_wrapper.py", line 60, in _call
    return PGoApiRequest.call(self)
  File "/home/junaos/PokemonGo-Bot/src/pgoapi/pgoapi/pgoapi.py", line 182, in call
    response = request.request(self._api_endpoint, self._req_method_list, self.get_position())
  File "/home/junaos/PokemonGo-Bot/src/pgoapi/pgoapi/rpc_api.py", line 106, in request
    response_dict = self._parse_main_response(response, subrequests)
  File "/home/junaos/PokemonGo-Bot/src/pgoapi/pgoapi/rpc_api.py", line 237, in _parse_main_response
    raise UnexpectedResponseException(error)
pgoapi.exceptions.UnexpectedResponseException: Unexpected HTTP server response - needs 200 got 502

Steps to Reproduce

Nothing in particular -- just started happening as of 23:25 UTC, is now happening frequently.

502 is bad gateway, so the servers may be overloaded; we should catch this exception and retry.

Other Information

OS: Ubuntu 14.04.4 LTS
Git Commit: bdf2e7d
Python Version: Python 2.7.6

@DayBr3ak
Copy link
Contributor

DayBr3ak commented Aug 2, 2016

Niantic is starting to change things ... getting this too, and some other like 'GET_INVENTORY']['inventory_delta']['inventory_items'] KeyError: 'inventory_delta'

@JSchwerberg
Copy link
Contributor Author

JSchwerberg commented Aug 2, 2016

Well, 502 is just an HTTP error code for Bad Gateway; I'm willing to put money on their infrastructure just being overloaded.
Either way, #2407 was submitted to catch this one and retry, using similar logic to your fixes for throttling in the refactor :)

@douglascamata
Copy link
Member

PR fixing merged.

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