-4

When ever we try to let google crawl our website we get several errors in sentry:

The value "213.55.176.155, 66.249.93.93" is not a valid IP address

or

The value "213.55.176.162, 66.102.9.18" is not a valid IP address.

The code error is coming from "$record = $reader->city($ip);"

$reader = new Reader('GeoLite2-City.mmdb');
        $record  = $reader->city($ip);
       // $ip = $_SERVER['REMOTE_ADDR'];
        $iso_code = $record->country->isoCode;
        $timezone = $record->location->timeZone;

We think its a AddressNotFoundException because the IP is not valid in geolite2 DB of maxmind.

Does anyone now how to avoid this error?

vanful
  • 102
  • 1
  • 11

1 Answers1

1

It looks like your string contains multiple IPs, so try splitting them and looping?

Something like:

$ips = explode(', ', $ip)
foreach(...) {
    ...
}
Travis Britz
  • 5,094
  • 2
  • 20
  • 35