diff --git a/lib/bunny/client08.rb b/lib/bunny/client08.rb
index c083a7e3f..064d81493 100644
--- a/lib/bunny/client08.rb
+++ b/lib/bunny/client08.rb
@@ -43,6 +43,7 @@ class Client < Qrack::Client
* :frame_max => maximum frame size in bytes (default = 131072)
* :channel_max => maximum number of channels (default = 0 no maximum)
* :heartbeat => number of seconds (default = 0 no heartbeat)
+* :timeout => number of seconds before Qrack::ConnectionTimeout is raised (default = 5)
=end
diff --git a/lib/bunny/client09.rb b/lib/bunny/client09.rb
index 935a707e2..f1bf46d4f 100644
--- a/lib/bunny/client09.rb
+++ b/lib/bunny/client09.rb
@@ -37,6 +37,7 @@ class Client09 < Qrack::Client
* :frame_max => maximum frame size in bytes (default = 131072)
* :channel_max => maximum number of channels (default = 0 no maximum)
* :heartbeat => number of seconds (default = 0 no heartbeat)
+* :timeout => number of seconds before Qrack::ConnectionTimeout is raised (default = 5)
=end
@@ -459,4 +460,4 @@ def buffer
end
end
-end
\ No newline at end of file
+end
diff --git a/lib/qrack/client.rb b/lib/qrack/client.rb
index 60ef23a0c..4590886d9 100644
--- a/lib/qrack/client.rb
+++ b/lib/qrack/client.rb
@@ -1,11 +1,12 @@
module Qrack
class ClientTimeout < Timeout::Error; end
+ class ConnectionTimeout < Timeout::Error; end
# Client ancestor class
class Client
- CONNECT_TIMEOUT = 1.0
+ CONNECT_TIMEOUT = 5.0
RETRY_DELAY = 10.0
attr_reader :status, :host, :vhost, :port, :logging, :spec, :heartbeat
@@ -25,6 +26,7 @@ def initialize(opts = {})
@frame_max = opts[:frame_max] || 131072
@channel_max = opts[:channel_max] || 0
@heartbeat = opts[:heartbeat] || 0
+ @connect_timeout = opts[:timeout] || CONNECT_TIMEOUT
@logger = nil
create_logger if @logging
@message_in = false
@@ -173,7 +175,7 @@ def socket
begin
# Attempt to connect.
- @socket = timeout(CONNECT_TIMEOUT) do
+ @socket = timeout(@connect_timeout, ConnectionTimeout) do
TCPSocket.new(host, port)
end