可能重复:
Link 1 , Link 2 , Link 3 , Link 4
无论如何,以上引用资料对我没有帮助!
代码:
require 'geocoder'
begin
Geocoder.configure(:timeout => 30)
geo_data = Geocoder.search("any_ip_address_here")
location = geo_data.first.data
country_code = location["country_code"]
puts "#{country_code}"
rescue => e
puts "#{e.message}"
end
gem :
地理编码器 (1.2.6)
错误:
“地理编码 api 响应速度不够快(使用 geocoder.configure(:timeout => ...) 设置限制)”
我在开发阶段和生产阶段随机收到此错误。为什么会这样?即使我已经完成了:
- 地理编码器默认超时为 15 到 30 秒。
- 每天 480 个请求。
除了上述内容之外,我还缺少任何其他内容吗? 请帮我解决这个问题。
提前致谢。
最佳答案
这在“地理编码服务”下的 README 中进行了描述。创建一个初始化程序(config/initializers/geocoder.rb)
并添加:
Geocoder::Configuration.timeout = 15
希望这对你有用:)
关于Ruby - 地理编码 api 响应速度不够快,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27105598/