Ruby on rails Ruby地理编码器连接被拒绝

Ruby on rails Ruby地理编码器连接被拒绝,ruby-on-rails,ruby,google-geocoder,rails-geocoder,Ruby On Rails,Ruby,Google Geocoder,Rails Geocoder,搜索IP地址时,出现以下错误: pry(main)> Geocoder.search("130.132.173.68") Geocoding API connection refused. => [] 如果我找别的东西,例如 pry(main)> Geocoder.search("new haven") 我得到了正确的结果。 freegeoip服务有问题吗?请确保您为Geocoder设置了具有所有配置设置的初始值设定项。这是我的问题。大致如下: #config/initia

搜索IP地址时,出现以下错误:

pry(main)> Geocoder.search("130.132.173.68")
Geocoding API connection refused.
=> []
如果我找别的东西,例如

pry(main)> Geocoder.search("new haven")
我得到了正确的结果。
freegeoip服务有问题吗?

请确保您为Geocoder设置了具有所有配置设置的初始值设定项。这是我的问题。大致如下:

#config/initializers/geocoder.rb

Geocoder.configure(  
 # geocoding options
 :timeout      => 7,           # geocoding service timeout (secs)
 :lookup       => :google,     # name of geocoding service (symbol)
 :language     => :en,         # ISO-639 language code
 :use_https    => true,        # use HTTPS for lookup requests? (if supported)
 :http_proxy   => '',          # HTTP proxy server (user:pass@host:port)
 :https_proxy  => '',          # HTTPS proxy server (user:pass@host:port)
 :api_key      => nil,         # API key for geocoding service
 :cache        => nil,         # cache object (must respond to #[], #[]=, and #keys)
 :cache_prefix => "geocoder:", # prefix (string) to use for all cache keys

 # IP address geocoding service (see below for supported options):
 #:ip_lookup => :maxmind,

 # to use an API key:
 #:api_key => "...",

 # exceptions that should not be rescued by default
 # (if you want to implement custom error handling);
 # supports SocketError and TimeoutError
 # :always_raise => [],

 # calculation options
 # :units     => :mi,       # :km for kilometers or :mi for miles
 # :distances => :linear    # :spherical or :linear
)

不确定这是否有任何重要性,但许多google web服务是通过https实现的。如果无法验证您的
crt
,它将拒绝。如果您使用的是windows,我强烈推荐
认证的
gem。只需安装
gem install certified
,然后在您进行这些调用的文件中安装
require certified
,看看它是否有任何变化。我不知道为什么会发生这种情况,因为当我逐字运行您的OP时,它对我很好。您确定使用谷歌进行IP查找吗?是的,我相信IP查找使用freegeoip