我尝试使用正确的amqp凭据启动amqp但它失败了。我在端口5678启动了rabbitmq服务器,我使用的是版本0.7.0的amqp gem,我使用的是ruby-1.9.2
以下是我在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>'
即使我尝试连接 Rabbitmq服务器5678 ,它也试图连接到默认端口
Could not connect to server 127.0.0.1:5672
为什么尝试连接到端口5672 ,即使我指定端口5678 ?
我无法弄清楚这一点并且坚持到这里
由于
答案 0 :(得分:0)
AMQP配置哈希将符号作为键而不是字符串。
require "amqp"
AMQP.start({:host => "localhost", :port => 5678}) do
puts "hello"
end
此外,您可能需要考虑升级到更新版本的gem。 CHANGELOG为0.7到0.9.x或1.0.0是几页长。