2013-05-14 85 views
2

我对rabbitmq非常陌生,我在一个EC2实例上安装rabbitmq-server,并且想要在另一个EC2实例上创建一个消费者。需要帮助确定主机名

但我发现了这个错误:

socket.gaierror: [Errno -2] Name or service not known 

这就是节点状态:

[email protected]:~$ sudo rabbitmq-server restart 
ERROR: node with name "rabbit" already running on "ip-10-147-xxx-xxx" 

DIAGNOSTICS 
=========== 

nodes in question: ['[email protected]'] 

hosts, their running nodes and ports: 
- ip-10-147-xxx-xxx: [{rabbit,46074},{rabbitmqprelaunch4603,51638}] 

current node details: 
- node name: '[email protected]' 
- home dir: /var/lib/rabbitmq 
- cookie hash: Gsnt2qHd7wWDEOAOFby= 

这就是消费者代码:

import pika 

cred = pika.PlainCredentials('guest', 'guest') 
conn_params = pika.ConnectionParameters('10-147-xxx-xxx', credentials=cred) 
conn_broker = pika.BlockingConnection(conn_params) 

conn_broker = pika.BlockingConnection(conn_params) 
channel = conn_broker.channel() 
channel.exchange_declare(exchange='hello-exchange', type='direct', passive=False, durable=True, auto_delete=False) 

channel.queue_declare(queue='hello-queue') 
channel.queue_bind(queue='hello-queue', exchange='hello-exchange', routing_key='hola') 

def msg_consumer(channel, method, header, body): 
    channel.basic_ack(delivery_tag=method.delivery_tag) 
    if body == 'quit': 
     channel.basic_cancel(consumer_tag='hello-consumer') 
     channel.stop_consuming() 
    else: 
     print body 

    return 

channel.basic_consume(msg_consumer, queue='hello-queue', consumer_tag='hello-consumer') 
channel.start_consuming() 
+0

你确定你打开了安全组的端口。此客户端也可以在安装兔子的服务器上工作。 – Bigtoe 2013-05-16 10:29:20

+0

这方面的进展如何? – Carl 2014-04-23 15:55:18

回答

0

您应该检查安全组允许你使用rabbitMQ端口,也似乎你没有使用Rabbit的默认端口(5672),所以它应该在你的连接参数