地理编码 api 对 IP 地址的响应速度不够快 [英] geocoding api not responding fast enough for IP address

查看:55
本文介绍了地理编码 api 对 IP 地址的响应速度不够快的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的生产服务器中,我使用了 Geocoder gem.但是,以下代码在服务器控制台中不起作用.

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")

我已将 geocoder.rb 文件配置为超时 30 秒.但它仍然给出错误 geocoding api 响应速度不够快

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

令人惊讶的是,每当我运行 Geocoder.search("San Francisco, CA") 时,它都会在几秒钟内给出结果.

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

我该怎么办?

推荐答案

我认为是 freegeoip 的问题,请尝试以下操作:

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

在 Rails 控制台中输入:

Enter this in your rails console:

Geocoder.configure(:ip_lookup => :telize)

Geocoder.configure(:ip_lookup => :telize)

现在尝试在控制台中搜索.

Now try you search in your console.

如果可行,您可以拥有您的文件 (config/initializers/geocoder.rb)

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

)

希望对您有所帮助.

这篇关于地理编码 api 对 IP 地址的响应速度不够快的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆