Geocoding API not responding fast enough

I use the Geocoder gem, but it has not been working lately.

I get this error:

Geocoding API not responding fast enough (use Geocoder.configure(:timeout => ...) to set limit).

My application_controller.rb:

before_filter :lookup_ip_location

  private

    def lookup_ip_location
      if Rails.env.development?
        prr = Geocoder.search(request.remote_ip).first
        p "this is #{prr.inspect}"
      else
        request.location
      end
    end

This is development.rb:

# test geocoder gem locally
  class ActionDispatch::Request
    def remote_ip
      "71.212.123.5" # ipd home (Denver,CO or Renton,WA)
      # "208.87.35.103" # websiteuk.com -- Nassau, Bahamas
      # "50.78.167.161" # HOL Seattle, WA
    end
  end

I am loading the IP addresses from development.rb to check if the geocoder works locally, but it is not. I get the above error.

Also, when printing, prrI get zero.

I also added the geocoder.rb initializer to raise the timeout to 15 seconds, but even 15 seconds after the page loads, I still get the same message.

Ruined? Should I use another stone? If yes, do you have any suggestions?

+4
source share
1

. . 60 .

, Geocoder freegeoip. , . , freegeoip.net . .

, Geocoder ip-, . , "Ip Address Services" . , API, :ipinfo_io.

[18] pry(main)> Geocoder.configure(ip_lookup: :ipinfo_io)
=> {:timeout=>30,
 :lookup=>:google,
 :ip_lookup=>:ipinfo_io,
 :language=>:en,
 :http_headers=>{},
 :use_https=>false,
 :http_proxy=>nil,
 :https_proxy=>nil,
 :api_key=>nil,
 :cache=>nil,
 :cache_prefix=>"geocoder:",
 :basic_auth=>{},
 :logger=>:kernel,
 :kernel_logger_level=>2,
 :always_raise=>[],
 :units=>:mi,
 :distances=>:linear}
[19] pry(main)> Geocoder.search("144.138.175.101")
=> [#<Geocoder::Result::IpinfoIo:0x007fce5da5fe28 @cache_hit=nil, @data={"ip"=>"144.138.175.101", "city"=>"", "region"=>"", "country"=>"AU", "loc"=>"-27.0000,133.0000"}>]

! . ip, Geocoder. . , freegeoip , . .

: freegeoip.net here. freegeoip, , . , !

+6

All Articles