Unable to connect to remote RabbitMQ server

I installed and configured RabbitMQ on a Ubuntu 16.04 server using the link . Since the default user, guest , is only allowed to connect locally by default, I added a new user with an administrator tag and set his permission so that he can access the virtual host / . I turned on the RabbitMQ management console. I can successfully log in with the user I created. I can also connect to RabbitMQ when I connect to it through localhost using my created user. But when I try to connect to the RabbitMQ server through other servers using the following code:

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

Gives an error message:

Traceback (last last call): File ", line 1, to File" / Library / Python / 2.7 / site-packages / pika / adapters / blocking_connection.py ", line 339, to init self._process_io_for_connection_setup () File" / Library / Python / 2.7 / site-packages / pika / adapters / blocking_connection.py ", line 374, in the file _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 the server where RabbitMQ is installed and replacing <server Public IP> with 0.0.0.0 .

Conclusion 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 can cause this error?

+5
source share
1 answer

this usually happens with a very low connection timeout. adjust the connection string to include a longer connection timeout, for example 30 or 60 seconds, and you should be kind.

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

+1
source

Source: https://habr.com/ru/post/1263257/


All Articles