In my Project, I'm testing the connection with remote Windows 2008 server, through ssh. I'm always getting the following error:
Errno::ETIMEDOUT: Connection timed out - connect(2)
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `initialize'
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `open'
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:70:in `block in initialize'
from /home/kamesh/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/timeout.rb:52:in `timeout'
from /home/kamesh/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/timeout.rb:97:in `timeout'
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh/transport/session.rb:67:in `initialize'
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh.rb:200:in `new'
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/net-ssh-2.8.0/lib/net/ssh.rb:200:in `start'
from /home/kamesh/projects/RubyApp/lib/connections/ssh_connection.rb:9:in `connect'
from (irb):5
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands/console.rb:90:in `start'
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands/console.rb:9:in `start'
from /home/kamesh/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
To ensure, what we're talking about the same thing - here's a link to Net::SSH GitHub page.
According to your error message, your ssh client can't connect to ssh server on another host.
First, you need to ensure that your server has server running. Here's a guide about how to install it on Windows Server 2008.
Second, you need to try and ping your server, to ensure if it's accessible through your network at all.
If there weren't any problems on previous stages, you can try to use Net::SSH again.
Related
When I try to run my rails app using
RAILS_ENV=production rails s -binding=128.199.95.219
I get this error
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:232:in `getaddrinfo': getaddrinfo: Name or service not known (SocketError)
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:232:in `foreach'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/socket.rb:459:in `tcp_server_sockets'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/utils.rb:70:in `create_listeners'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:133:in `listen'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:114:in `initialize'
from /usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:45:in `initialize'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/handler/webrick.rb:31:in `new'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/handler/webrick.rb:31:in `run'
from /usr/local/rvm/gems/ruby-2.2.1/gems/rack-1.6.4/lib/rack/server.rb:286:in `start'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/server.rb:80:in `start'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:75:in `server'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.2.1/gems/railties-4.2.4/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I've googled many places but still find no definite answer which could solve this problem.
My app is running in Ubuntu (14.0.4) with Nginx and Unicorn at DigitalOcean
Any idea anyone?
Use a double dash for the binding parameter, i.e.:
RAILS_ENV=production rails s --binding=128.199.95.219
See rails s --help for more info.
I am trying to send email using SMTP server onheroku run rails console but getting some error. But it is working absolutely fine on local system, not able to understand what's the problem.
Code:
message = <<MESSAGE_END
From: Jobs<notification#example.com>
To: Ajay Gupta<ajaygupta#example.com>
Subject: SMTP e-mail test
This is a test e-mail message.
MESSAGE_END
Net::SMTP.start('SMTP_URL') do |smtp|
smtp.send_message 'message', 'ajaygupta#example.com', 'ajaygupta#example.com'
end
Error: when run the above code on heroku console
Net::OpenTimeout: execution expired
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:541:in `initialize'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:541:in `open'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:541:in `tcp_socket'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:551:in `block in do_start'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:550:in `do_start'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:520:in `start'
from /app/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/smtp.rb:457:in `start'
from (irb):3
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:90:in `start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands/console.rb:9:in `start'
from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/commands.rb:64:in `<top (required)>'
from /app/bin/rails:4:in `require'
from /app/bin/rails:4:in `<main>'
It appears based on your call heroku run rails console, that you are trying to run this on a Heroku based server. According to Heroku's own docs, you are only allowed to send email using an external service, such as SendGrid or other providers.
I have a mongod running at my network's internal subnet of 10.1.150.24 and my mogoid.yml has these lines:
hosts:
- 10.1.150.24:27017
MongoDB is running without authentication on the remote server.
On the remote server a rails app with - localhost:27017 connects without issues. The mongod.conf has
net:
bindIp: 0.0.0.0
set and should accept connections on all interfaces.
I can see the connection error when I am in rails c on my local and try to create an object or even retrieve one.
Foo.create(...) failes like this:
TypeError: no implicit conversion of nil into String
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/protocol/commands/authenticate.rb:35:in `+'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/protocol/commands/authenticate.rb:35:in `digest'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/protocol/commands/authenticate.rb:47:in `build_auth_command'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/protocol/commands/authenticate.rb:25:in `initialize'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/authenticatable.rb:71:in `new'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/authenticatable.rb:71:in `login'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/authenticatable.rb:28:in `block in apply_credentials'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/authenticatable.rb:26:in `each'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/authenticatable.rb:26:in `apply_credentials'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/node.rb:180:in `block in ensure_connected'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/node.rb:115:in `block in connection'
from /var/lib/gems/2.2.0/gems/connection_pool-2.1.1/lib/connection_pool.rb:62:in `with'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/node.rb:114:in `connection'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/node.rb:178:in `ensure_connected'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/node.rb:589:in `block in flush'
from /var/lib/gems/2.2.0/gems/moped-2.0.3/lib/moped/node.rb:617:in `block in logging'
... 33 levels...
from /var/lib/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/console.rb:9:in `start'
from /var/lib/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:68:in `console'
from /var/lib/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /var/lib/gems/2.2.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in `<top (required)>'
from /var/lib/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /var/lib/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
from /var/lib/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /var/lib/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
from /home/mwerner/workspace/pricing/bin/rails:8:in `<top (required)>'
from /var/lib/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /var/lib/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `block in load'
from /var/lib/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
from /var/lib/gems/2.2.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:268:in `load'
from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
Given the number of authentication errors with moped I am confused since there is no authentication on the mongo instance.
EDIT: I also tried ssh tunneling the 27017 port to my local and setting localhost in monogoid.yml No luck
running sudo gem pristine --all and killing the spring process fixed the issue. I can now connect to the remote server.
I have an operation in my Heroku-hosted Rails app that runs in a background process and calls out to a government website that is slow. I am receiving a timeout error (at the bottom below) that I haven't been able to fix.
The read timeout appears happen at 20 seconds into the request.
The following line causes the problem:
Mechanize.new.get('http://ai.fmcsa.dot.gov/SMS/Data/Search.aspx')
Is there an environment variable that fixes this? Something else that I'm missing?
Errno::ETIMEDOUT: Connection timed out - connect(2)
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `initialize'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `open'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `block in connect'
from /usr/local/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
from /usr/local/lib/ruby/1.9.1/timeout.rb:89:in `timeout'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `connect'
from /usr/local/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
from /usr/local/lib/ruby/1.9.1/net/http.rb:632:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent.rb:768:in `reset'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent.rb:503:in `connection_for'
from /app/vendor/bundle/ruby/1.9.1/gems/net-http-persistent-2.7/lib/net/http/persistent.rb:806:in `request'
from /app/vendor/bundle/ruby/1.9.1/gems/mechanize-2.5.1/lib/mechanize/http/agent.rb:258:in `fetch'
from /app/vendor/bundle/ruby/1.9.1/gems/mechanize-2.5.1/lib/mechanize.rb:407:in `get'
from /app/app/models/inspection.rb:14:in `fmcsa_summary'
from (irb):5
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
from /app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
The solution that worked as a temporary fix was to use a proxy server via Mechanize. There must be something going on between the server that I'm connecting to and the IP address range of the Heroku EC2 instances.
agent = Mechanize.new { |a| a.set_proxy(url,port,username,password) }
It would still be helpful if someone knew the root cause of the original problem.
I have one rails project and two machinges. One is running Ubuntu 10.04 and the other 12.04 beta. I'm using the 'fb_graph' gem on the 10.04 machine all works fine, but when I do on the 12.04 machine things like
me = FbGraph::User.me(token).fetch
I get
HTTPClient::ConnectTimeoutError: execution expired
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:300:in `connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:300:in `ssl_connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:739:in `block in connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:731:in `connect'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:594:in `query'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient/session.rb:161:in `query'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:1060:in `do_get_block'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:869:in `block in do_request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:956:in `protect_keep_alive_disconnected'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:868:in `do_request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:756:in `request'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/httpclient-2.2.4/lib/httpclient.rb:661:in `get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:49:in `block in get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:122:in `handle_response'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:48:in `get'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/fb_graph-2.4.10/lib/fb_graph/node.rb:18:in `fetch'
from (irb):10
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/railties-3.2.0/lib/rails/commands/console.rb:47:in `start'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/railties-3.2.0/lib/rails/commands/console.rb:8:in `start'
from /home/jan/.rvm/gems/ruby-1.9.2-p290#ece/gems/railties-3.2.0/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have no idea why this happen nor how I could solve it. Any ideas? Thanks!
Jan
Reasons it could be happening are hardware performance of the machine, and network performance.
Try it again a couple times. Sometimes the network needs time to load routing information, but once it's loaded it goes faster the next times. That may not be a good production solution, but it could diagnose if the problem is freshening the network routing.
This could be a true network performance issue. That might not help you, if you cannot tune your network.
If re-trying helps, you could put a re-try loop around your code.
(0..2).each do
begin
... #your code goes here
break
rescue HTTPClient::ConnectTimeoutError
end
end
The HTTP request is timing out between the server and FB. See this github issue for an explanation of how to configure the HTTP client's timeout option.