【发布时间】:2014-11-24 13:07:24
【问题描述】:
可能的重复:
以上参考对我没有帮助!
代码:
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
宝石:
地理编码器 (1.2.6)
错误:
“地理编码 API 响应不够快(使用 geocoder.configure(:timeout => ...) 设置限制)”
我在开发阶段和生产阶段随机收到此错误。为什么会这样?即使我已经完成了:
- 地理编码器默认超时时间为 15 到 30 秒。
- 每天 480 个请求。
除了上述之外,我还有什么遗漏吗? 请帮我解决这个问题。
提前致谢。
【问题讨论】:
-
使用 3rd 方服务会发生这种情况 - 您应该将 API 调用移至后台作业并在失败时重试。
-
这里可能的解决方案:stackoverflow.com/questions/26093393/…希望对您有所帮助!
标签: ruby gem rubygems geocoding