在我的本地机器中,我可以:
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
对于这两个脚本(send.py和recv.py),以便建立正确的通信,但是如何建立从12.23.45.67到132.45.23.14的通信?我知道ConnectionParameters()接受的所有参数,但我不确定要传递给主机或客户端的参数。如果有人能给出一个主机脚本和客户端脚本的例子,将不胜感激。
发布于 2015-01-07 23:07:13
请参阅http://pika.readthedocs.org/en/latest/modules/parameters.html,其中显示'rabbit-server1'
您应该输入IP的远程主机名。
请注意,guest
帐户只能通过本地主机https://www.rabbitmq.com/access-control.html进行连接
发布于 2016-06-13 01:59:07
第一步是向您的rabbitMQ服务器添加另一个帐户。要在windows中执行此操作...
现在,如果您按照以下send.py修改中所做的那样修改连接信息,您应该会看到成功:
#!/usr/bin/env python
import pika
credentials = pika.PlainCredentials('the_user', 'the_pass')
parameters = pika.ConnectionParameters('132.45.23.14',
5672,
'/',
credentials)
connection = pika.BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue='hello')
channel.basic_publish(exchange='',
routing_key='hello',
body='Hello W0rld!')
print(" [x] Sent 'Hello World!'")
connection.close()
希望这能有所帮助
https://stackoverflow.com/questions/27805086
复制相似问题