Sha256: 0c628bb7e5a600d77a18e0b4628a5a271b7d78a51d6d5127d358b3caba5e61ed

Contents?: true

Size: 860 Bytes

Versions: 63

Compression:

Stored size: 860 Bytes

Contents

#!/usr/bin/env ruby
# encoding: utf-8

require "bundler"
Bundler.setup

$:.unshift(File.expand_path("../../../lib", __FILE__))

require 'amqp'


puts "=> Authentication failure handling with a rescue block"
puts

handler             = Proc.new { |settings| puts "Failed to connect, as expected"; EM.stop }
connection_settings = {
  :port     => 5672,
  :vhost    => "/amq_client_testbed",
  :user     => "amq_client_gem",
  :password => "amq_client_gem_password_that_is_incorrect #{Time.now.to_i}",
  :timeout        => 0.3,
  :on_tcp_connection_failure => handler
}


begin
  AMQP.start(connection_settings) do |connection, open_ok|
    raise "This should not be reachable"
  end
rescue AMQP::PossibleAuthenticationFailureError => afe
  puts "Authentication failed, as expected, caught #{afe.inspect}"
  EventMachine.stop if EventMachine.reactor_running?
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
amqp-0.9.2 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.9.1 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.9.0 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.9.0.pre3 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.9.0.pre2 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.9.0.pre1 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.4 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.3 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.2 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.1 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc15 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc14 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc13 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc12 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc11 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc10 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc9 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc8 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb
amqp-0.8.0.rc7 examples/error_handling/handling_authentication_failure_with_a_rescue_block.rb