Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

ruby on rails - geocoding api not responding fast enough for IP address

In my production server I've used the Geocoder gem. But, the following code not working in the server console.

Geocoder.search("192.168.1.4")

I've configured my geocoder.rb file with timeout 30 seconds. But still it gives the error geocoding api not responding fast enough

Surprisingly, whenever i ran Geocoder.search("San Francisco, CA") it gives the result within seconds.

What should i do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I think it is an issue with freegeoip, try the following:

Enter this in your rails console:

Geocoder.configure(:ip_lookup => :telize)

Now try you search in your console.

if this works you can have your file (config/initializers/geocoder.rb)

Geocoder.configure(

  :timeout=>20,

  :lookup=>:yandex,

  :ip_lookup=>:telize,

  :language=>:en,

  :http_headers=>{},

  :use_https=>false,

  :http_proxy=>nil,

  :https_proxy=>nil,

  :api_key=>nil,

  :cache=>nil,

  :cache_prefix=>"geocoder:",

  :units=>:km,

  :distances=>:linear

)

I hope this help you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...