无法远程访问RabbitMq服务器

问题描述 投票:0回答:1

我无法远程访问RabbitMq服务器。当我在一台机器上执行此操作并连接到localhost:15672时,它可以工作,但是当我从远程计算机上尝试时,它却没有。

我已经创建了一个具有所有权限的用户,并检查计算机上的5672端口是否可用(只是尝试从远程计算机连接到该用户)。另外,我尝试连接到15672端口,但没有结果。

credentials = pika.PlainCredentials(username= 'username', password='password')
parameters = pika.ConnectionParameters(host='188.19.100.226',
                                   port=5672,
                                   virtual_host= '/',
                                   credentials=credentials)

connection = pika.BlockingConnection(parameters=parameters)
channel = connection.channel()

channel.queue_declare(queue='hello')

channel.basic_publish(exchange='',
                  routing_key='hello',
                  body=hello)
print ("Sent!")
connection.close()

我希望看到已发送!,但我得到的却不是:

ERROR:pika.adapters.utils.io_services_utils:Socket failed to connect: <socket.socket fd=7, family=AddressFamily.AF_INET, type=2049, proto=6, laddr=('192.168.100.2', 44752)>; error=111 (Connection refused)
ERROR:pika.adapters.utils.connection_workflow:TCP Connection attempt failed: ConnectionRefusedError(111, 'Connection refused'); dest=(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('188.19.100.226', 5672))
ERROR:pika.adapters.utils.connection_workflow:AMQPConnector - reporting failure: AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused')
ERROR:pika.adapters.utils.connection_workflow:AMQP connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused'); first exception - None.
ERROR:pika.adapters.utils.connection_workflow:AMQPConnectionWorkflow - reporting failure: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused'); first exception - None
ERROR:pika.adapters.blocking_connection:Connection workflow failed: AMQPConnectionWorkflowFailed: 1 exceptions in all; last exception - AMQPConnectorSocketConnectError: ConnectionRefusedError(111, 'Connection refused'); first exception - None
ERROR:pika.adapters.blocking_connection:Error in _create_connection().
Traceback (most recent call last):
  File "/home/roman/PycharmProjects/trrp2/venv/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
    raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AMQPConnectionError
Traceback (most recent call last):
  File "/home/roman/PycharmProjects/trrp2/send.py", line 52, in <module>
    connection = pika.BlockingConnection(parameters=parameters)
  File "/home/roman/PycharmProjects/trrp2/venv/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 359, in __init__
    self._impl = self._create_connection(parameters, _impl_class)
  File "/home/roman/PycharmProjects/trrp2/venv/lib/python3.6/site-packages/pika/adapters/blocking_connection.py", line 450, in _create_connection
    raise self._reap_last_connection_workflow_error(error)
pika.exceptions.AMQPConnectionError
python linux rabbitmq ip pika
1个回答
0
投票

您需要配置rabbitmq来侦听本地主机以外的其他接口。要接受来自所有接口的连接,请收听0.0.0.0

https://www.rabbitmq.com/networking.html#interfaces

© www.soinside.com 2019 - 2024. All rights reserved.