Sha256: d1c5c84b0ec2b1b9f33c7d059d1c26c7ef165dc4ec6c302225dc92c10127d423

Contents?: true

Size: 897 Bytes

Versions: 56

Compression:

Stored size: 897 Bytes

Contents

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

require "bundler"
Bundler.setup

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

require 'amqp'


puts "=> Authentication failure/vhost misconfiguration handling with a rescue block"
puts

handler             = Proc.new { |settings| puts "Failed to connect, as expected"; EM.stop }
connection_settings = {
  :port     => 5672,
  :vhost    => "/a/b/c/d/#{rand}/#{Time.now.to_i}",
  :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

56 entries across 56 versions & 1 rubygems

Version Path
amqp-1.1.2 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.1.1 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.1.0 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.0.3 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.1.0.rc1 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.1.0.pre2 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.1.0.pre1 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.0.2 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.0.1 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.0.0 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-0.9.10 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-0.9.9 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-0.9.8 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.0.0.pre2 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-0.9.7 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-0.9.6 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-1.0.0.pre1 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-0.9.5 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-0.9.4 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb
amqp-0.9.3 examples/error_handling/handling_vhost_misconfiguration_with_a_rescue_block.rb