2

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.

Community
  • 1
  • 1
user2580202
  • 43
  • 1
  • 5
  • Welcome to Stack Overflow. Read http://stackoverflow.com/help/how-to-ask on how to ask a good question. I'd suggest either posting some code or giving more details about what you have already tried, and what problems you are running in to. Your question is overly broad and assumes that people are fully aware of the tutorial you are talking about – JamesENL May 08 '14 at 01:36
  • Read this post: http://stackoverflow.com/questions/23487238/client-cant-connect-to-remote-rabbitmq-server – Gabriele Santomaggio May 08 '14 at 06:05
  • Got it! It was the configuration setup. With guest user it only works with localhost! Thank you! Gas – user2580202 May 08 '14 at 19:09
  • you are welcome @user2580202 ! I report the answer for future reader – Gabriele Santomaggio May 09 '14 at 14:46

2 Answers2

3

The problem is the new rabbitmq access control policy

Please read this : RabbitMQ client can't connect to remote RabbitMQ server

or read this : Can't access RabbitMQ web management interface after fresh install

Community
  • 1
  • 1
Gabriele Santomaggio
  • 21,656
  • 4
  • 52
  • 52
0

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