lib/flydata/compatibility_check.rb in flydata-0.2.12 vs lib/flydata/compatibility_check.rb in flydata-0.2.13
- old
+ new
@@ -37,25 +37,29 @@
TCP_PORT=45326
SSL_PORT=45327
def check_outgoing_ports
- unless can_connect_to_port?(TCP_PORT) and
- can_connect_to_port?(SSL_PORT)
- raise AgentCompatibilityError,
- "Cannot connect to outisde ports. Please check to make sure you have these outgoing ports open: #{TCP_PORT},#{SSL_PORT}"
- end
- end
+ ports = [TCP_PORT]
+ ports << SSL_PORT unless ENV['FLYDATA_ENV_KEY'] == 'development'
- private
- def can_connect_to_port?(port)
url = @dp["servers"].first
- begin
- e = TCPSocket.new(url, port)
- e.close
- return true
- rescue Errno::ETIMEDOUT => e
- return false
+ errors = {}
+ ports.each do |port|
+ begin
+ e = TCPSocket.new(url, port)
+ e.close
+ rescue => e
+ errors[port] = e
+ end
+ end
+
+ unless errors.empty?
+ message = "Cannot connect to outisde ports. Please check to make sure you have these outgoing ports open."
+ errors.each do |port, e|
+ message += " Port #{port}, Error #{e.class.name}: #{e.to_s}"
+ end
+ raise AgentCompatibilityError, message
end
end
end
class MysqlCompatibilityCheck < CompatibilityCheck