linux – RabbitMQ,麻烦得到hello world示例除了localhost之外的任何东西

我正在学习RabbitMQ,并在 http://www.rabbitmq.com/tutorials/tutorial-one-python.html运行hello world示例,localhost没有问题.现在我想测试从我的PC到另一台服务器的消息,receive.py似乎永远不会得到任何消息.也许我没有正确指定主机名?

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))

解决方法

RabbitMQ – http://www.rabbitmq.com/configure.html

见frame_max.认情况下支持128KB.您可能想要在安装中检查该设置.

相关文章

在Linux上编写运行C语言程序,经常会遇到程序崩溃、卡死等异...
git使用小结很多人可能和我一样,起初对git是一无所知的。我...
1. 操作系统环境、安装包准备 宿主机:Max OSX 10.10.5 虚拟...
因为业务系统需求,需要对web服务作nginx代理,在不断的尝试...
Linux模块机制浅析 Linux允许用户通过插入模块,实现干预内核...
一、Hadoop HA的Web页面访问 Hadoop开启HA后,会同时存在两个...