Skip to content

IP Geocoder (freegeoip) errors when adding Resource #216

Description

@justb4

Seeing errors for freegeoip when requesting lat-lon location:

TLDR;

  • implement freegeoip new API as described here
  • implies requesting API key (NB max 10000 reqs a month!)
  • optional: allow user-supplied API key
  • once stable again implement Configurable geocoder #210 for a more flexible IP-geocoder solution
2018-10-08 11:13:40,509 - GeoHealthCheck.util - INFO - Geocoding geodata.nationaalgeoregister.nl with http://freegeoip.net/json/geodata.nationaalgeoregister.nl
2018-10-08 11:13:40,585 - GeoHealthCheck.util - ERROR - Could not derive coordinates: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "/GeoHealthCheck/GeoHealthCheck/util.py", line 162, in geocode
    content = json.loads(urlopen(url).read())
  File "/usr/local/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/local/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/local/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python2.7/urllib2.py", line 467, in error
    result = self._call_chain(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 654, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/usr/local/lib/python2.7/urllib2.py", line 435, in open
    response = meth(req, response)
  File "/usr/local/lib/python2.7/urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/local/lib/python2.7/urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "/usr/local/lib/python2.7/urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
2018-10-08 11:13:40,590 - GeoHealthCheck.models - ERROR - Could not derive coordinates: Could not derive coordinates: HTTP Error 403: Forbidden
Traceback (most recent call last):
  File "/GeoHealthCheck/GeoHealthCheck/models.py", line 382, in __init__
    self.latitude, self.longitude = util.geocode(url)
  File "/GeoHealthCheck/GeoHealthCheck/util.py", line 167, in geocode
    raise ValueError(msg)
ValueError: Could not derive coordinates: HTTP Error 403: Forbidden
2

So we'll need a fix anyway, as freegeoip has changed API and conditions, http://freegeoip.net/shutdown:


{
--
  | "0": "#################################################################################################################################",
  | "1": "#                                                                                                                               #",
  | "2": "# IMPORTANT - PLEASE UPDATE YOUR API ENDPOINT                                                                                   #",
  | "3": "#                                                                                                                               #",
  | "4": "# This API endpoint is deprecated and has now been shut down. To keep using the freegeoip API, please update your integration   #",
  | "5": "# to use the new ipstack API endpoint, designed as a simple drop-in replacement.                                                #",
  | "6": "# You will be required to create an account at https://ipstack.com and obtain an API access key.                                #",
  | "7": "#                                                                                                                               #",
  | "8": "# For more information on how to upgrade please visit our Github Tutorial at: https://github.com/apilayer/freegeoip#readme      #",
  | "9": "#                                                                                                                               #",
  | "a": "#################################################################################################################################"
  | }


Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions