geocoding api not responding fast enough for IP address

℡╲_俬逩灬. 提交于 2019-12-18 09:25:55

问题


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?


回答1:


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.




回答2:


Have you tried using your Public facing IP instead of the internal IP you are using?

IP address geocoding often returns results for the organization which owns the IP address block instead of the actual computer IP address. This is because IP address geocoding does not consider private IPs, VPNs, or internal network blocks.




回答3:


I get this error when i am not connected to the internet..pls verify that you have an active internet or you are bypassing the proxy.



来源:https://stackoverflow.com/questions/26093393/geocoding-api-not-responding-fast-enough-for-ip-address

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!