EHOSTUNREACH when a FTP connection cannot be established #5754
Is it possible to make the error convey that the remote host is unavailable or unreachable like MRI does with
I think that
I looked at #5709 (comment) and wonder if it is even possible to raise a
Please feel free to close this if this cannot be considered an issue with JRuby.
The text was updated successfully, but these errors were encountered:
The proper error does get raised, but then the logic in socket.rb attempts to close the not-quite-established connection and raises EBADF.
Tweaking the logic to not raise EBADF and show the intermediate errors exposes a further problem, however: we are not picking the right exception type for these errors. The first two here are the exceptions live near the
These two errors should be ETIMEDOUT and EHOSTUNREACH.
This allows failed connections from sockets (jruby#5709, jruby#5754) to raise the actual socket error even though the logic in socket.rb tries to close the failed socket. This approach differs from jruby#5713 in that it modifies the final flush logic to skip closed channels rather than modifying the IO#closed? logic to do that same check.
Because the case of a socket that fails to connect has special behavior for us (the socket is closed or never opened by JDK) we force it to clean up after a connect fails due to a ConnectException. This may be valid for other failures but I am limiting scope of this special case for now. See jruby#5754.