RabbitMQ, trouble getting hello world example to work on anything but localhost

fred basset asked:

I’m learning RabbitMQ and have run the hello world example at http://www.rabbitmq.com/tutorials/tutorial-one-python.html without problems on localhost. Now I want to test messaging from my PC to a different server, receive.py never seems to get any messages. Perhaps I’m not specifying the hostnames correctly?

Receive.py:


#!/usr/bin/env python
import pika
import json

connection = pika.BlockingConnection(pika.ConnectionParameters(
        host='66.175.x.x'))
channel = connection.channel()

channel.queue_declare(queue='hello')

print ' [*] Waiting for messages. To exit press CTRL+C'

def callback(ch, method, properties, body):
    data = json.loads(body)
    print "Log filename is " + data["filename"]
    print data["content"]

channel.basic_consume(callback,
                      queue='hello',
                      no_ack=True)

channel.start_consuming()

send.py:


#!/usr/bin/env python
import pika
import json
import sys

filename = sys.argv[1]
logdata = open(filename, 'r').read()

connection = pika.BlockingConnection(pika.ConnectionParameters(
        host='66.175.x.x'))
channel = connection.channel()

channel.queue_declare(queue='logupload')
n = filename.rfind('\')
if n != -1:
    filename = filename[n + 1:]
data = {"filename":filename, "logdata":logdata}

channel.basic_publish(exchange='',
                      routing_key='logupload',
                      body=json.dumps(data))
connection.close()
print "sent %s %d bytes" % (filename, len(logdata))

My answer:


Make sure rabbitmq is actually listening on port 5672 and that the port is open in your Linode server’s firewall.

In your config, RABBITMQ_NODE_IP_ADDRESS should be blank, RABBITMQ_NODE_PORT should be 5672.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.