502 Bad Gateway

37 views
Skip to first unread message

Tom Curran

unread,
Mar 8, 2016, 1:32:01 PM3/8/16
to Open State Project
Hello - 

Trying to use the geo_search function in openstates by iterating the function through each row of a data frame containing the latitude and longitude. 

for item in geo:
lat = geo['Latitude']
lon = geo['Longitude']
ok_rep = sunlight.openstates.legislator_geo_search(lat, lon)
print(ok_rep)

But I keep getting the following trace error:

Traceback (most recent call last):
  File "/Users/TomCurran/PycharmProjects/Plotly/sunglight_senate.py", line 22, in <module>
    ok_rep = sunlight.openstates.legislator_geo_search(lat, lon)
  File "/Library/Python/2.7/site-packages/sunlight/services/openstates.py", line 103, in legislator_geo_search
    return self.get(["legislators", "geo"], **kwargs)
  File "/Library/Python/2.7/site-packages/sunlight/service.py", line 83, in get
    raise ex
sunlight.errors.BadRequestException: 'Error (502) -- <html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor="white">\r\n<center><h1>502 Bad Gateway</h1></center>\r\n<hr><center>nginx/1.4.1 (Ubuntu)</center>\r\n</body>\r\n</html>\r\n'

However, When I enter the raw numbers (e.g. sunlight.openstates.legislator_geo_search('10.0001', '-20.0001') I get the desired results.

Suggestions?

dmc...@sunlightfoundation.com

unread,
Mar 9, 2016, 9:44:14 AM3/9/16
to Open State Project
Hi Tom,

Thanks for using our applications. I was wondering if your project is available on a public repo?
Also, I noticed you didn't use "item" in your iteration. 
Did you intend to use "item['Latitude']"?

Thank you,

Don McLamb
Software Developer 
Sunlight Foundation

Chris Brown

unread,
Mar 17, 2016, 12:18:12 PM3/17/16
to Open State Project
We're having this same issue through the Python API and even just trying to connect to the service using a browser. I tried the example from the documentation:


and I'm receiving the 502 error.

This happened last year to us as well and replacing our key fixed it but no such luck this time around.

Chris

Andy Lo

unread,
Mar 17, 2016, 3:07:56 PM3/17/16
to Open State Project
The geolocation endpoints should be up and running again.  We've been experiencing issues with the internal service which serves those endpoints recently, and are currently looking into improving stability.

Chris Brown

unread,
Mar 17, 2016, 3:58:12 PM3/17/16
to Open State Project
Thanks! It is working in our application again.
Reply all
Reply to author
Forward
0 new messages