Skip to content

EHOSTUNREACH when a FTP connection cannot be established #5754

@Adithya-copart

Description

@Adithya-copart

Expected Behavior

Is it possible to make the error convey that the remote host is unavailable or unreachable like MRI does with EHOSTUNREACH?

I think that Errno::EBADF (Bad file descriptor - No message available) do not convey that the FTP server/host is unreachable.

I looked at #5709 (comment) and wonder if it is even possible to raise a EHOSTUNREACH.

Please feel free to close this if this cannot be considered an issue with JRuby.

JRuby:

jruby-9.2.7.0 :001 > require 'net/ftp'
 => true 
jruby-9.2.7.0 :002 > Net::FTP.open('example.com', 'test', 'password') do |ftp_conn|
jruby-9.2.7.0 :003 >     puts ftp_conn.nlst("*")
jruby-9.2.7.0 :004?>   end
Traceback (most recent call last):
       16: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/net/ftp.rb:163:in `open'
       15: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/net/ftp.rb:265:in `initialize'
       14: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/net/ftp.rb:367:in `connect'
       13: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/monitor.rb:226:in `mon_synchronize'
       12: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/net/ftp.rb:369:in `block in connect'
       11: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/net/ftp.rb:328:in `open_socket'
       10: from org/jruby/ext/timeout/Timeout.java:75:in `timeout'
        9: from org/jruby/ext/timeout/Timeout.java:82:in `timeout'
        8: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/net/ftp.rb:333:in `block in open_socket'
        7: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/socket.rb:638:in `tcp'
        6: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/socket.rb:229:in `foreach'
        5: from org/jruby/RubyArray.java:1792:in `each'
        4: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/socket.rb:648:in `block in tcp'
        3: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/socket.rb:139:in `connect'
        2: from /Users/adpentela/.rvm/rubies/jruby-9.2.7.0/lib/ruby/stdlib/socket.rb:69:in `connect_internal'
        1: from org/jruby/ext/socket/RubySocket.java:694:in `close'
Errno::EBADF (Bad file descriptor - No message available)

MRI:

irb(main):001:0> require 'net/ftp'
=> true
irb(main):002:0> Net::FTP.open('example.com', 'test', 'password') do |ftp_conn|
irb(main):003:1* puts ftp_conn.nlst("*")
irb(main):004:1> end
Traceback (most recent call last):
       16: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/ftp.rb:163:in `open'
       15: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/ftp.rb:163:in `new'
       14: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/ftp.rb:269:in `initialize'
       13: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/ftp.rb:370:in `connect'
       12: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/monitor.rb:230:in `mon_synchronize'
       11: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/ftp.rb:372:in `block in connect'
       10: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/ftp.rb:332:in `open_socket'
        9: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/timeout.rb:76:in `timeout'
        8: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/net/ftp.rb:337:in `block in open_socket'
        7: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/socket.rb:631:in `tcp'
        6: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/socket.rb:227:in `foreach'
        5: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/socket.rb:227:in `each'
        4: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/socket.rb:641:in `block in tcp'
        3: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/socket.rb:137:in `connect'
        2: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/socket.rb:64:in `connect_internal'
        1: from /Users/adpentela/.rvm/rubies/ruby-head/lib/ruby/2.7.0/socket.rb:64:in `connect'
Errno::EHOSTUNREACH (No route to host - connect(2) for [2606:2800:220:1:248:1893:25c8:1946]:21)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions