New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed issue with reconnect mechanism #251
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,7 +285,7 @@ def start | |
@logger.warn "Retrying connection on next host in line: #{@transport.host}:#{@transport.port}" | ||
|
||
return self.start | ||
rescue Exception | ||
rescue | ||
@status_mutex.synchronize { @status = :not_connected } | ||
raise | ||
end | ||
|
@@ -961,13 +961,11 @@ def open_connection | |
fr | ||
# frame timeout means the broker has closed the TCP connection, which it | ||
# does per 0.9.1 spec. | ||
rescue Errno::ECONNRESET, ClientTimeout, AMQ::Protocol::EmptyResponseError, EOFError, IOError => e | ||
rescue | ||
nil | ||
end | ||
if frame.nil? | ||
@state = :closed | ||
@logger.error "RabbitMQ closed TCP connection before AMQP 0.9.1 connection was finalized. Most likely this means authentication failure." | ||
raise Bunny::PossibleAuthenticationFailureError.new(self.user, self.vhost, self.password.size) | ||
raise TCPConnectionFailed.new('An empty frame was received while opening the connection. In RabbitMQ <= 3.1 this could mean an authentication issue.') | ||
end | ||
|
||
response = frame.decode_payload | ||
|
@@ -1011,13 +1009,11 @@ def open_connection | |
fr | ||
# frame timeout means the broker has closed the TCP connection, which it | ||
# does per 0.9.1 spec. | ||
rescue Errno::ECONNRESET, ClientTimeout, AMQ::Protocol::EmptyResponseError, EOFError => e | ||
rescue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the intent here? Rescue everything? Then it should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would StandardError not suffice here? Is there any reasons we should catch the base Exception class in this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, looks like it's fine. |
||
nil | ||
end | ||
if frame2.nil? | ||
@state = :closed | ||
@logger.warn "RabbitMQ closed TCP connection before AMQP 0.9.1 connection was finalized. Most likely this means authentication failure." | ||
raise Bunny::PossibleAuthenticationFailureError.new(self.user, self.vhost, self.password.size) | ||
raise TCPConnectionFailed.new('An empty frame was received while opening the connection. In RabbitMQ <= 3.1 this could mean an authentication issue.') | ||
end | ||
connection_open_ok = frame2.decode_payload | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to be careful here and catch everything. We could add some logging though.