How can devices communicate using rabbitmq with IP address?

218 views
Skip to first unread message

Peng Jin

unread,
Sep 3, 2016, 7:08:15 AM9/3/16
to rabbitmq-users
Hello All,

I copied the "Hello World" example from the website and it worked. But when I tried to replace the 'localhost' with my own IP address, it did not work and showed the following:

Traceback (most recent call last):

  File "/Users/Tony/Documents/code/send.py", line 5, in <module>

    host='192.168.1.102')

  File "/Library/Python/2.7/site-packages/pika/adapters/blocking_connection.py", line 339, in __init__

    self._process_io_for_connection_setup()

  File "/Library/Python/2.7/site-packages/pika/adapters/blocking_connection.py", line 374, in _process_io_for_connection_setup

    self._open_error_result.is_ready)

  File "/Library/Python/2.7/site-packages/pika/adapters/blocking_connection.py", line 395, in _flush_output

    raise exceptions.ConnectionClosed()

pika.exceptions.ConnectionClosed


I thought it was because of the remote access. So I added another username instead of guest with full rights and I can log in the web UI on other remote devices. Then I did the modification like this:

 #!/usr/bin/env python
import pika
credentials = pika.PlainCredentials('jin','passwd')
connection = pika.BlockingConnection(pika.ConnectionParameters(
        host='192.168.1.102',
        port=5672,
        virtual_host='/')
        )

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

But it still shows: 

Traceback (most recent call last):

  File "/Users/Tony/Documents/code/send.py", line 7, in <module>

    virtual_host='/')

  File "/Library/Python/2.7/site-packages/pika/adapters/blocking_connection.py", line 339, in __init__

    self._process_io_for_connection_setup()

  File "/Library/Python/2.7/site-packages/pika/adapters/blocking_connection.py", line 374, in _process_io_for_connection_setup

    self._open_error_result.is_ready)

  File "/Library/Python/2.7/site-packages/pika/adapters/blocking_connection.py", line 395, in _flush_output

    raise exceptions.ConnectionClosed()

pika.exceptions.ConnectionClosed


And I cannot telnet into the port: 

Trying 192.168.1.102...

telnet: connect to address 192.168.1.102: Connection refused

telnet: Unable to connect to remote host

Can anyone please guide me how to fix the problem and give me an example how two devices communicate with each other using rabbitmq? 

Sorry about too many questions.

Thank you very much.

Michael Klishin

unread,
Sep 3, 2016, 7:17:35 AM9/3/16
to rabbitm...@googlegroups.com
If telnet cannot connect then it's likely a matter of opening the ports on the server machine. You can find the list on http://rabbitmq.com/networking.html.
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages