0

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?

Ishank Gupta
  • 1,575
  • 1
  • 14
  • 19
Sudhir
  • 311
  • 1
  • 2
  • 7

1 Answers1

0

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 :-)

pmoo
  • 321
  • 1
  • 3