0

I tried to start amqp with the correct amqp credential but it fails. I have started rabbitmq server at port 5678 and I am using amqp gem of version 0.7.0 and I am using ruby-1.9.2

Here are the logs for what I have done in irb

± irb
/Users/ckgagan/.rvm/rubies/ruby-1.9.2-p320/bin/irb:4: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
1.9.2-p320 :001 > require 'mq'
 => true 
1.9.2-p320 :002 > AMQP.start({"host"=>"localhost", "port"=>5678, "user"=>"username", "password"=>"password"}) do
1.9.2-p320 :003 >     puts "hello"
1.9.2-p320 :004?>   end
AMQP::Error: Could not connect to server 127.0.0.1:5672
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/amqp-0.7.0/lib/amqp/client.rb:76:in `block in initialize'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/amqp-0.7.0/lib/amqp/client.rb:107:in `call'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/amqp-0.7.0/lib/amqp/client.rb:107:in `block in unbind'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:959:in `call'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:959:in `block in run_deferred_callbacks'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:956:in `times'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:956:in `run_deferred_callbacks'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run_machine'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/eventmachine-1.0.0/lib/eventmachine.rb:187:in `run'
    from /Users/ckgagan/.rvm/gems/ruby-1.9.2-p320@my_gemset/gems/amqp-0.7.0/lib/amqp.rb:81:in `start'
    from (irb):2
    from /Users/ckgagan/.rvm/rubies/ruby-1.9.2-p320/bin/irb:16:in `<main>'

Even though I tried to connect Rabbitmq server at 5678, its trying to connect to default port

Could not connect to server 127.0.0.1:5672

Why is it trying to connect to port 5672 even though I specified port 5678?

I am unable to figure this out and stuck here

Thanks

Gagan
  • 4,278
  • 7
  • 46
  • 71

1 Answers1

0

The AMQP configuration hash takes symbols as keys, not strings.

require "amqp"

AMQP.start({:host => "localhost", :port => 5678}) do
  puts "hello"
end

Also, you might want to consider upgrading to a more recent version of the gem. The CHANGELOG for 0.7 to 0.9.x or 1.0.0 is a couple of pages long.

Tim Potter
  • 2,437
  • 21
  • 31