Вопрос

The hello world example in the tutorial section of rabbitMQ, asks just to change the hostname with the ip of the different machine. But that isn't working for me. I have tried Binding external IP address to Rabbit MQ server​ but that didn't work. Is there something else that i need to do to the configuration file or the code?

Here is the sending code

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters(
    host='ip_address'))
channel = connection.channel()

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='',
                  routing_key='hello',
                  body='Hello World!')
print " [x] Sent 'Hello World!'"
connection.close()

And my receiving code which I am running on another machine

#!/usr/bin/env python
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters(
    host='ip_address'))
channel = connection.channel()

channel.queue_declare(queue='hello1')

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

def callback(ch, method, properties, body):
    print " [x] Received %r" % (body,)

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

channel.start_consuming()

And the error I am getting is

No handlers could be found for logger "pika.adapters.base_connection"
Traceback (most recent call last):

File "send.py", line 25, in <module>
'ip_address'))
 File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py",    line 107, in __init__
   super(BlockingConnection, self).__init__(parameters, None, False)
 File "/usr/local/lib/python2.7/dist-packages/pika/adapters/base_connection.py", line 62, in __init__
on_close_callback)
 File "/usr/local/lib/python2.7/dist-packages/pika/connection.py", line 590, in __init__
self.connect()
 File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 206, in connect
   if not self._adapter_connect():
 File "/usr/local/lib/python2.7/dist-packages/pika/adapters/blocking_connection.py", line 275, in _adapter_connect
raise exceptions.AMQPConnectionError(1)
pika.exceptions.AMQPConnectionError: 1

I appreciate for you guys to take the time to help me.

Это было полезно?

Другие советы

I had to do diff things on local implementation for 2 machines maybe some of them can help you: On server !important: change your node from config file rabbitmq-env.conf to run on machine's network ip restart rabbitmq afterwards

 brew services stop rabbitmq 
 brew services start rabbitmq

*you can find rabbitmq config file with

find / -name rabbitmq-env.conf

In project:

credentials = pika.PlainCredentials(env.RABBITMQ_USER, env.RABBITMQ_PASSWORD)
    connection = pika.BlockingConnection(pika.ConnectionParameters(env.RABBITMQ_IP, port=env.RABBITMQ_PORT, virtual_host='/', credentials=credentials))
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top