diff --git a/lib/httpx/connection.rb b/lib/httpx/connection.rb index 7c4fb102..bc2b0c3e 100644 --- a/lib/httpx/connection.rb +++ b/lib/httpx/connection.rb @@ -522,14 +522,15 @@ module HTTPX Errno::ENETUNREACH, Errno::EPIPE, Errno::ENOENT, - SocketError => e + SocketError, + IOError => e # connect errors, exit gracefully error = ConnectionError.new(e.message) error.set_backtrace(e.backtrace) connecting? && callbacks_for?(:connect_error) ? emit(:connect_error, error) : handle_error(error) @state = :closed emit(:close) - rescue TLSError => e + rescue TLSError, HTTP2Next::Error::ProtocolError, HTTP2Next::Error::HandshakeError => e # connect errors, exit gracefully handle_error(e) connecting? && callbacks_for?(:connect_error) ? emit(:connect_error, e) : handle_error(e) diff --git a/lib/httpx/io/tcp.rb b/lib/httpx/io/tcp.rb index ea990f6d..a16ad73a 100644 --- a/lib/httpx/io/tcp.rb +++ b/lib/httpx/io/tcp.rb @@ -78,7 +78,8 @@ module HTTPX rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL, Errno::EHOSTUNREACH, - SocketError => e + SocketError, + IOError => e raise e if @ip_index <= 0 log { "failed connecting to #{@ip} (#{e.message}), trying next..." }