5

I have installed and configured RabbitMQ on Ubuntu 16.04 server using reference. Since the default user that is guest is only allowed to connect locally by default, I added a new user with the administrator tag and set its permission so that it can access / virtual host. I enabled RabbitMQ management console. I am successfully able to login with the user I created. I am also able to connect with RabbitMQ when I am connecting to it via localhost using my created user. But when I am trying to connect with the RabbitMQ server through other servers using following code:

import pika
credentials = pika.PlainCredentials('new_user', 'new_pass')
parameters = pika.ConnectionParameters('<server's Public IP>', 5672,'/',credentials)
connection = pika.BlockingConnection(parameters)

It throws an error:

Traceback (most recent call last): File "", line 1, in 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

The same code works fine when I run this code on server, on which RabbitMQ is installed and by replacing <server's Public IP> with 0.0.0.0.

Output of sudo netstat -nltp

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:25672           0.0.0.0:*               LISTEN      18021/beam
tcp        0      0 0.0.0.0:4369            0.0.0.0:*               LISTEN      18110/epmd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1230/sshd
tcp        0      0 0.0.0.0:15672           0.0.0.0:*               LISTEN      18021/beam
tcp6       0      0 :::5672                 :::*                    LISTEN      18021/beam
tcp6       0      0 :::4369                 :::*                    LISTEN      18110/epmd
tcp6       0      0 :::22                   :::*                    LISTEN      1230/sshd

What could be causing this error?

1 Answer 1

2

this usually happens with a very low connection timeout. adjust your connection string to include a larger connection timeout, such as 30 or 60 seconds, and you should be good to go.

looks like pika uses this setting https://pika.readthedocs.io/en/latest/modules/parameters.html#pika.connection.ConnectionParameters.blocked_connection_timeout

Sign up to request clarification or add additional context in comments.

1 Comment

I am able to connect remotely as well with some internet networks like jio and even with aws ec2 instances. But when I use other internet service, it throws above mentioned error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.