samedi 9 avril 2016

Geocoding API not responding fast enough error message

i am using geocoder gem but lately it does not seem to work.

error

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

in 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

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

so basically i am loading ip addresses from the development.rb file to check if geocoder works locally but it does not i am getting the above.

also when printing the prr variable i get nil.

I also added a geocoder.rb initializer to raise the timeout to 15 seconds but even after 15 seconds of browser loading page still getting same message. Is it broken? Should i use another gem? if so, do you have any suggestions?

Aucun commentaire:

Enregistrer un commentaire