I am getting following error when I am trying to connect the FTP server
ftp = Net::FTP::new("example.sg","username","password")
Errno::ECONNREFUSED: Connection refused - Connection refused
from org/jruby/ext/socket/RubyTCPSocket.java:121:in `initialize'
from org/jruby/RubyIO.java:876:in `new'
from org/jruby/ext/socket/RubyTCPSocket.java:147:in `open'
from /opt/jruby/lib/ruby/1.8/net/ftp.rb:159:in `open_socket'
from /opt/jruby/lib/ruby/1.8/net/ftp.rb:175:in `connect'
from /opt/jruby/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
from /opt/jruby/lib/ruby/1.8/net/ftp.rb:174:in `connect'
from /opt/jruby/lib/ruby/1.8/net/ftp.rb:136:in `initialize'
from (irb):7:in `evaluate'
from org/jruby/RubyKernel.java:1083:in `eval'
from /opt/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input'
from /opt/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status'
from /opt/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1410:in `loop'
from org/jruby/RubyKernel.java:1183:in `catch'
from /opt/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input'
from /opt/jruby/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1183:in `catch'
from /opt/jruby/lib/ruby/1.8/irb.rb:70:in `start'
from /opt/jruby/bin/jirb:13:in `(root)
I am able to access the same website from a browser using ftp://example.sg.
Any ideas why net/ftp would have issues accessing the site?
Works using JRuby 1.7.4:
Welcome to the JRuby IRB Console [1.7.4 (1.9.3)]
irb(main):001:0> require 'net/ftp'
true
irb(main):002:0> ftp = Net::FTP.new('ftp.ruby-lang.org', 'anonymous', '')
#<Net::FTP:0x4e2d4656 #mon_count=0, #mon_owner=nil, #logged_in=true, #sock=#<TCPSocket:fd19>, #last_response="200 Switching to Binary mode.\n", #last_response_code="200", #passive=false, #resume=false, #binary=true, #debug_mode=false, #welcome="230 Login successful.\n", #mon_mutex=#<Mutex:0x7e64e032>>
irb(main):003:0> ftp.list
["drwxrwxr-x 5 106 111 4096 Dec 25 23:42 pub"]
Is it working for you if you try ruby-lang.org site?
I see that you used Net::FTP::new instead of Net::FTP.new, but it shouldn't matter :-)
Related
Trying to connect locally deployed openstack (pike) with fog.
Firstly, curl connection works well with the command:
https://hastebin.com/fihojuqize.scala
With this in mind, i've created fog credentials file: https://hastebin.com/hexanixucu.scala and run
fog openstack
Compute[:openstack].servers
This leads to an error like (full text here)
:status => 302
:status_line => "HTTP/1.1 302 Found\r\n"
from /var/lib/gems/2.3.0/gems/excon-0.60.0/lib/excon/middlewares/expects.rb:7:in `response_call'
from /var/lib/gems/2.3.0/gems/excon-0.60.0/lib/excon/middlewares/response_parser.rb:9:in `response_call'
from /var/lib/gems/2.3.0/gems/excon-0.60.0/lib/excon/connection.rb:414:in `response'
from /var/lib/gems/2.3.0/gems/excon-0.60.0/lib/excon/connection.rb:263:in `request'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/connection.rb:81:in `request'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/openstack.rb:610:in `get_version'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/openstack.rb:583:in `get_supported_microversion'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/openstack/core.rb:122:in `set_microversion'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/openstack/core.rb:212:in `authenticate'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/compute/openstack.rb:397:in `initialize'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/service.rb:115:in `new'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/service.rb:115:in `new'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:16:in `new'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/compute.rb:54:in `new'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:4:in `[]'
from (irb):1:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/fog-1.42.0/bin/fog:76:in `block in <top (required)>'
from /var/lib/gems/2.3.0/gems/fog-1.42.0/bin/fog:76:in `catch'
from /var/lib/gems/2.3.0/gems/fog-1.42.0/bin/fog:76:in `<top (required)>'
from /usr/local/bin/fog:23:in `load'
from /usr/local/bin/fog:23:in `<main>'
First request to "/identity/v3/auth/tokens" was complete, but overall result is bad..
Worth to be mentioned - i've cntlm proxy configured.
Export your openrc file which contains authentication information like this
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS
export OS_TENANT_NAME=admin
export OS_AUTH_URL=http://controller:35357/v3.0
I tried the below code:
require 'mechanize'
agent = Mechanize.new{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE}
page = agent.get "https://gegsltraining.aravo.com/"
page=page.link_with(:dom_class => "button").click()
But my bad getting the below error.
D:\WIPData\Ruby\Scripts>mechanize_dowload.rb
C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net/http/persist
ent/ssl_reuse.rb:29:in `initialize': getaddrinfo: No such host is known. (Socke
tError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `open'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `block in connect'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `connect'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:750:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:628:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:570:in `connection_for'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:926:in `request'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.5.1/lib/mechanize/h
ttp/agent.rb:258:in `fetch'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.5.1/lib/mechanize.r
b:407:in `get'
from D:/WIPData/Ruby/Scripts/mechanize_dowload.rb:5:in `<main>'
D:\WIPData\Ruby\Scripts>
The same script ran perfectly on my personal machine,but not in my company.
Could you please me to fix the same?
Thanks in advance
That error means dns is not resolving. In my experience it's usually because your internet is down.
I am getting this error
C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:141:in `read_nonblock': An existing connection was forcibly closed by the remote host. (Errno::ECONNRESET)
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:in `request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1064:in `head'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/chrome/service.rb:63:in `block in stop'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in `start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:557:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/chrome/service.rb:59:in `stop'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/chrome/bridge.rb:50:in `quit'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/common/driver.rb:166:in `quit'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:87:in `close'
from test_google.rb:9:in `block in <main>'
from test_google.rb:5:in `times'
from test_google.rb:5:in `<main>'
whenever I run tests successively. I believe it is a webdriver/selenium bug, but would like if someone could help me fix or determine the cause.
Here is some code you can try running in irb:
20.times { b = Watir::Browser.new :chrome; b.goto "http://google.com"; p b.div.exists?; b.close;}
EDIT: I updated my ChromeDriver and do not receive the error for the above code.
In order to fix this try updating your Chrome Driver: http://code.google.com/p/chromedriver/downloads/list
I have a mobile app built using Rhomobile. When I launch an image upload from the phone to the rails server I end up with timeout issues on larger pictures (2+ MBs). I get an error in Mongrel on server side (Rails 2.3.8) and a CURL timeout error on the phone side. Is the timeout an issue from the phone or from the mongrel server?
Mongrel error:
Wed Oct 19 09:07:05 -0500 2011: Error reading HTTP body: #<RuntimeError: Socket read returned insufficient data: 13515>
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_request.rb:107:in `read_socket'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_request.rb:86:in `read_body'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_request.rb:55:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:149:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:149:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19
Error in Rhomobile App:
Net| Operation finished with error 28: Timeout was reached
Net| CURLNetRequest: METHOD = [POST] URL = [http://www.mywebsite.com/updload/upload_image ] BODY = []
I use the AsyncHttp.upload_file command.
I m trying to upload a file through attachment fu to amazon s3 storage using the following code :-
has_attachment :storage => :s3,
:content_type =>
['audio/mp3','audio/flac','audio/wav'],
:path_prefix => '#####',
:output_path => '######',
:processor => :none
But get the following error:-
Connection refused - connect(2)
Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/1.8/net/http.rb:560:in `initialize'
/usr/lib/ruby/1.8/net/http.rb:560:in `open'
/usr/lib/ruby/1.8/net/http.rb:560:in `connect'
/usr/lib/ruby/1.8/timeout.rb:53:in `timeout'
/usr/lib/ruby/1.8/timeout.rb:93:in `timeout'
/usr/lib/ruby/1.8/net/http.rb:560:in `connect'
/usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
/usr/lib/ruby/1.8/net/http.rb:542:in `start'
vendor/plugins/aws-s3/lib/aws/s3/connection.rb:52:in `request'
vendor/plugins/aws-s3/lib/aws/s3/base.rb:69:in `request'
vendor/plugins/aws-s3/lib/aws/s3/base.rb:88:in `put'
vendor/plugins/aws-s3/lib/aws/s3/object.rb:241:in `store'
vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb:294:in `save_to_storage'
vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:369:in `after_process_attachment'
vendor/rails/activerecord/lib/active_record/callbacks.rb:307:in `send'
vendor/rails/activerecord/lib/active_record/callbacks.rb:307:in `callback'
vendor/rails/activerecord/lib/active_record/callbacks.rb:304:in `each'
vendor/rails/activerecord/lib/active_record/callbacks.rb:304:in `callback'
vendor/rails/activerecord/lib/active_record/callbacks.rb:214:in `create_or_update'
vendor/rails/activerecord/lib/active_record/base.rb:1973:in `save_without_validation'
vendor/rails/activerecord/lib/active_record/validations.rb:927:in `save_without_transactions'
vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:80:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:100:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save'
vendor/rails/activerecord/lib/active_record/transactions.rb:120:in `rollback_active_record_state!'
vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save'
vendor/rails/activerecord/lib/active_record/base.rb:2035:in `update_attributes'
app/models/track_file.rb:45:in `upload'
app/controllers/media_controller.rb:202:in `track_update'
app/controllers/application.rb:157:in `access_session_value_in_models'
like ruby is stating you cannot connect to the s3 server for some reason.
make some connectivity test on your server using the telnet command.
i.e. telnet s3.amazonaws.com 80