RubyMoney / google_currency

Ruby Money::Bank interface for the Google Currency exchange data
http://rubymoney.github.com/google_currency
MIT License
182 stars 90 forks source link

Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com" #33

Closed bnussey closed 9 years ago

bnussey commented 9 years ago

Hello,

Firstly thanks for the great gem, we have been using it with great success in the past months.

I have just started getting a Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com" from this gem but can't think of any changes made that would cause this. Do you have any ideas why this could be? I have tried updating to the latest gem version but to no effect.

Thanks very much.

rake db:migrate                                                                                                                                       
rake aborted!                                                                                                                                                                                                                       
Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com" port 80                                                                                                                                                
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:128:in `fetch_rate'                                                                                                                       
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:99:in `block in get_rate'                                                                                                                 
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `synchronize'                                                                                                                       
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `get_rate'                                                                                                                          
/home/action/workspace/trendosaur/lib/tasks/import_newstyle.rake:22:in `block in <top (required)>'                                                                                                                                  
/home/action/workspace/trendosaur/lib/tasks/import_newstyle.rake:1:in `<top (required)>'                                                                                                                                            
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'                                                                                                                              
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `block in load'                                                                                                                     
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'                                                                                                                   
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'                                                                                                                              
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `block in run_tasks_blocks'                                                                                                                             
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `each'                                                                                                                                                  
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `run_tasks_blocks'                                                                                                                                      
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/application.rb:362:in `run_tasks_blocks'                                                                                                                                 
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:449:in `load_tasks'                                                                                                                                            
/home/action/workspace/trendosaur/Rakefile:6:in `<top (required)>'                                                                                                                                                                  
(See full trace by running task with --trace)                   
bnussey commented 9 years ago

Here is the full trace:

rake aborted!                                                                                                                                                                                                                       
Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com" port 80                                                                                                                                                
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:879:in `initialize'                                                                                                                                           
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:879:in `open'                                                                                                                                                 
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:879:in `block in connect'                                                                                                                                     
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/timeout.rb:76:in `timeout'                                                                                                                                                
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:878:in `connect'                                                                                                                                              
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:863:in `do_start'   
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/net/http.rb:852:in `start'                                                                                                                                                
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:313:in `open_http'                                                                                                                                            
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:724:in `buffer_open'                                                                                                                                          
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:210:in `block in open_loop'                                                                                                                                   
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:208:in `catch'                                                                                                                                                
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:208:in `open_loop'                                                                                                                                            
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:149:in `open_uri'                                                                                                                                             
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:704:in `open'                                                                                                                                                 
/home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/open-uri.rb:712:in `read'                                                                                                                                                 
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:128:in `fetch_rate'                                                                                                                       
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:99:in `block in get_rate'                                                                                                                 
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `synchronize'                                                                                                                       
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in `get_rate'                                                                                                                          
/home/action/workspace/trendosaur/lib/tasks/import_newstyle.rake:22:in `block in <top (required)>'                                                                                                                                  
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/task_manager.rb:209:in `in_namespace'                                                                                                                                        
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/dsl_definition.rb:146:in `namespace'                                                                                                                                         
/home/action/workspace/trendosaur/lib/tasks/import_newstyle.rake:1:in `<top (required)>'                                                                                                                                            
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'                                                                                                                              
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `block in load'                                                                                                                     
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in `load_dependency'                                                                                                                   
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in `load'                                                                                                                              
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `block in run_tasks_blocks'                                                                                                                             
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `each'                                                                                                                                                  
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in `run_tasks_blocks'                                                                                                                                      
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/application.rb:362:in `run_tasks_blocks'                                                                                                                                 
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:449:in `load_tasks'                                                                                                                                            
/home/action/workspace/trendosaur/Rakefile:6:in `<top (required)>'                                                                                                                                                                  
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/rake_module.rb:28:in `load'                                                                                                                                                  
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/rake_module.rb:28:in `load_rakefile'                                                                                                                                         
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/application.rb:687:in `raw_load_rakefile'                                                                                                                                    
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/application.rb:94:in `block in load_rakefile'                                                                                                                                
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'                                                                                                                          
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/application.rb:93:in `load_rakefile'                                                                                                                                         
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/application.rb:77:in `block in run'                                                                                                                                          
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/application.rb:176:in `standard_exception_handling'                                                                                                                          
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/lib/rake/application.rb:75:in `run'                                                                                                                                                   
/home/action/.gem/ruby/2.1.1/gems/rake-10.3.2/bin/rake:33:in `<top (required)>'                                                                                                                                                     
/home/action/.gem/ruby/2.1.1/bin/rake:23:in `load'                                                                                                                                                                                  
/home/action/.gem/ruby/2.1.1/bin/rake:23:in `<main>'
semmons99 commented 9 years ago

No idea there. Can you directly access the endpoint outside of the gem?

On Wed, Apr 8, 2015 at 11:45 AM, bnussey notifications@github.com wrote:

Hello, Firstly thanks for the great gem, we have been using it with great success in the past months. I have just started getting a Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com" from this gem but can't think of any changes made that would cause this. Do you have any ideas why this could be? I have tried updating to the latest gem version but to no effect. Thanks very much. rake db:migrate
rake aborted!
Errno::ENETUNREACH: Network is unreachable - connect(2) for "www.google.com" port 80
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:128:in fetch_rate' /home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:99:inblock in get_rate'
/home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:in synchronize' /home/action/.gem/ruby/2.1.1/gems/google_currency-3.2.0/lib/money/bank/google_currency.rb:98:inget_rate'
/home/action/workspace/trendosaur/lib/tasks/import_newstyle.rake:22:in block in <top (required)>' /home/action/workspace/trendosaur/lib/tasks/import_newstyle.rake:1:in<top (required)>'
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:in load' /home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:inblock in load'
/home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:232:in load_dependency' /home/action/.gem/ruby/2.1.1/gems/activesupport-4.1.0/lib/active_support/dependencies.rb:241:inload'
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in block in run_tasks_blocks' /home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:ineach'
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:654:in run_tasks_blocks' /home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/application.rb:362:inrun_tasks_blocks'
/home/action/.gem/ruby/2.1.1/gems/railties-4.1.0/lib/rails/engine.rb:449:in load_tasks' /home/action/workspace/trendosaur/Rakefile:6:in<top (required)>'

(See full trace by running task with --trace)

Reply to this email directly or view it on GitHub: https://github.com/RubyMoney/google_currency/issues/33

bnussey commented 9 years ago

Hey @semmons99 thanks for the help. Hmm I am able to access and use the gem absolutely fine from the console so now I am really confused:

irb(main):005:0> require 'money'                                                                                                                                                                                                    
=> false                                                                                                                                                                                                                            
irb(main):006:0> require 'money/bank/google_currency'                                                                                                                                                                               
=> true                                                                                                                                                                                                                             
irb(main):007:0> bank = Money::Bank::GoogleCurrency.new                                                                                                                                                                             
=> #<Money::Bank::GoogleCurrency:0x007fa04c70c9e0 @rounding_method=nil, @rates={}, @mutex=#<Mutex:0x007fa04c70c990>>                                                                                                                
irb(main):008:0> gbp = bank.get_rate(:USD, :GBP).to_f                                                                                                                                                                               
=> 0.6702                                                                                                                                                                                                                           
irb(main):009:0> Money::Bank::GoogleCurrency.ttl_in_seconds = 86400                                                                                                                                                                 
=> 86400                                                                                                                                                                                                                            
irb(main):010:0> Money::Bank::GoogleCurrency.ttl_in_seconds = 1                                                                                                                                                                     
=> 1                                                                                                                                                                                                                                
irb(main):011:0> gbp = bank.get_rate(:USD, :GBP).to_f                                                                                                                                                                               
=> 0.6703                                                                                                                                                                                                                           
irb(main):012:0> gbp = bank.get_rate(:USD, :GBP).to_f                                                                                                                                                                               
=> 0.6703                                                                                                                                                                                                                           
irb(main):013:0> gbp = bank.get_rate(:USD, :GBP).to_f                                                                                                                                                                               
=> 0.6703                                                                                                                                                                                                                           
irb(main):014:0> gbp = bank.get_rate(:USD, :GBP).to_f                                                                                                                                                                               
=> 0.6703                                                                                                                                                                                                                           
irb(main):015:0> gbp = bank.get_rate(:USD, :GBP).to_f                                                                                                                                                                               
=> 0.6703                                                                               
bnussey commented 9 years ago

And here's the code I am using that has been working absolutely fine up until now:

# Currency Conversion

require 'money'
require 'money/bank/google_currency'

# set the seconds after than the current rates are automatically expired

Money::Bank::GoogleCurrency.ttl_in_seconds = 86400

# set default bank to instance of GoogleCurrency

bank = Money::Bank::GoogleCurrency.new

@gbp = bank.get_rate(:USD, :GBP).to_f
@eur = bank.get_rate(:USD, :EUR).to_f
@aud = bank.get_rate(:USD, :AUD).to_f      
@cad = bank.get_rate(:USD, :CAD).to_f    
@nzd = bank.get_rate(:USD, :NZD).to_f  

# Currency Calculation

# Price            

# GBP

def gbp_currency_conversion
    @gbp * @price
end

# EUR

def eur_currency_conversion
    @eur * @price
end

# AUD

def aud_currency_conversion
    @aud * @price
end

# CAD   

def cad_currency_conversion
    @cad * @price
end

#NZD

def nzd_currency_conversion
    @nzd * @price
end

# Revenue

# GBP            

def gbp_revenue_currency_conversion
    @gbp * @revenue
end

# EUR

def eur_revenue_currency_conversion
    @eur * @revenue
end

# AUD

def aud_revenue_currency_conversion
    @aud * @revenue
end

# CAD   

def cad_revenue_currency_conversion
    @cad * @revenue
end

#NZD

def nzd_revenue_currency_conversion
    @nzd * @revenue
end
semmons99 commented 9 years ago

Is there something on your production box blocking access to the endpoint?

On Wed, Apr 8, 2015 at 1:04 PM, bnussey notifications@github.com wrote:

And here's the code I am using that has been working absolutely fine up until now:

# Currency Conversion
require 'money'
require 'money/bank/google_currency'
# set the seconds after than the current rates are automatically expired
Money::Bank::GoogleCurrency.ttl_in_seconds = 86400
# set default bank to instance of GoogleCurrency
bank = Money::Bank::GoogleCurrency.new
@gbp = bank.get_rate(:USD, :GBP).to_f
@eur = bank.get_rate(:USD, :EUR).to_f
@aud = bank.get_rate(:USD, :AUD).to_f      
@cad = bank.get_rate(:USD, :CAD).to_f    
@nzd = bank.get_rate(:USD, :NZD).to_f  
# Currency Calculation
# Price            
# GBP
def gbp_currency_conversion
    @gbp * @price
end
# EUR
def eur_currency_conversion
    @eur * @price
end
# AUD
def aud_currency_conversion
    @aud * @price
end
# CAD   
def cad_currency_conversion
    @cad * @price
end
#NZD
def nzd_currency_conversion
    @nzd * @price
end
# Revenue
# GBP            
def gbp_revenue_currency_conversion
    @gbp * @revenue
end
# EUR
def eur_revenue_currency_conversion
    @eur * @revenue
end
# AUD
def aud_revenue_currency_conversion
    @aud * @revenue
end
# CAD   
def cad_revenue_currency_conversion
    @cad * @revenue
end
#NZD
def nzd_revenue_currency_conversion
    @nzd * @revenue
end

Reply to this email directly or view it on GitHub: https://github.com/RubyMoney/google_currency/issues/33#issuecomment-90976160

bnussey commented 9 years ago

well this is actually in dev, production is fine. i telnet google.com 80 from the dev area and it is all working.. so weird

bnussey commented 9 years ago

ok now it is working without me changing anything... i am so confused! I will close the issue, thank you mate for your help and time.

Pysis868 commented 8 years ago

For me, this happened on my system when trying to perform a gem download, completely unrelated to koala, and it was because for our project, we need to download its gems through a proxy, and have the "HTTP_PROXY" terminal environment variable set, along with "HTTPS_PROXY". These seem to enable a proxy path for common commands such as curl, and maybe even wget as well.

When I loaded a fresh terminal environment without those variable set lines in my .bashrc file, then it worked fine.

So that may be your problem.