diff --git a/lib/aerospike/node.rb b/lib/aerospike/node.rb index b2799e7b..2c6a1b8e 100644 --- a/lib/aerospike/node.rb +++ b/lib/aerospike/node.rb @@ -120,6 +120,7 @@ def put_connection(conn) def tend_connection if @tend_connection.nil? || @tend_connection.closed? @tend_connection = Cluster::CreateConnection.(cluster, host) + @tend_connection.timeout = cluster.connection_timeout end @tend_connection end diff --git a/lib/aerospike/node_validator.rb b/lib/aerospike/node_validator.rb index 471c8bc9..5a5fe36b 100644 --- a/lib/aerospike/node_validator.rb +++ b/lib/aerospike/node_validator.rb @@ -20,12 +20,13 @@ module Aerospike class NodeValidator # :nodoc: - attr_reader :host, :aliases, :name, :features, :cluster_name, :tls_options, :conn + attr_reader :host, :timeout, :aliases, :name, :features, :cluster_name, :tls_options, :conn def initialize(cluster, host, timeout, cluster_name, tls_options = {}) @cluster = cluster @features = Set.new @host = host + @timeout = timeout @cluster_name = cluster_name @tls_options = tls_options @@ -44,6 +45,7 @@ def get_hosts(address) begin conn = Cluster::CreateConnection.(@cluster, Host.new(address, host.port, host.tls_name)) + conn.timeout = timeout commands = %w[node features] commands << address_command unless is_loopback?(address) diff --git a/spec/aerospike/node_validator_spec.rb b/spec/aerospike/node_validator_spec.rb index 80561cef..81a93205 100644 --- a/spec/aerospike/node_validator_spec.rb +++ b/spec/aerospike/node_validator_spec.rb @@ -21,6 +21,7 @@ before do allow(socket).to receive(:write).and_return(nil) allow(socket).to receive(:read).and_return(nil) + allow(socket).to receive(:timeout=).and_return(nil) expect(::Aerospike::Cluster::CreateConnection).to receive(:call).and_return(socket) end @@ -31,6 +32,7 @@ let(:hosts) { [::Aerospike::Host.new('192.168.1.1', '3000')] } before do + allow(socket).to receive(:timeout=).and_return(nil) allow(::Aerospike::Cluster::CreateConnection).to receive(:call).and_return(socket) expect(::Aerospike::Info).to receive(:request).and_return( @@ -49,6 +51,7 @@ let(:hosts) { [::Aerospike::Host.new('my.lb.com', '3000')] } before do + allow(socket).to receive(:timeout=).and_return(nil) allow(::Aerospike::Cluster::CreateConnection).to receive(:call).and_return(socket) expect(Resolv).to receive(:getaddresses).and_return(['101.1.1.1', '102.1.1.1']) @@ -79,6 +82,7 @@ let(:policy) { ::Aerospike::ClientPolicy.new(tls: { enable: true }) } before do + allow(socket).to receive(:timeout=).and_return(nil) allow(::Aerospike::Cluster::CreateConnection).to receive(:call).and_return(socket) expect(Resolv).to receive(:getaddresses).and_return(['101.1.1.1', '102.1.1.1'])