aiopika RPC模式示例在以下情况下崩溃:RobustConnection:连接已关闭

2024-09-27 21:27:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用RPC Pattern运行带有aio-pika的RPC。我在文档中按原样运行,只是更改了AMPQ URL,但出现了一个错误:

Task exception was never retrieved
quart_service_01_1  | future: <Task finished coro=<RobustConnection.reconnect() done, defined at /usr/local/lib/python3.6/site-packages/aio_pika/robust_connection.py:149> exception=RuntimeError('<RobustConnection: "amqp://dev_user:******@rabbit:5672/tgvhost" 1 channels> connection closed',)>
quart_service_01_1  | Traceback (most recent call last):
quart_service_01_1  |   File "/usr/local/lib/python3.6/asyncio/tasks.py", line 180, in _step
quart_service_01_1  |     result = coro.send(None)
quart_service_01_1  |   File "/usr/local/lib/python3.6/site-packages/aio_pika/robust_connection.py", line 150, in reconnect
quart_service_01_1  |     await self.connect()
quart_service_01_1  |   File "/usr/local/lib/python3.6/site-packages/aio_pika/robust_connection.py", line 105, in connect
quart_service_01_1  |     raise RuntimeError("{!r} connection closed".format(self))
quart_service_01_1  | RuntimeError: <RobustConnection: "amqp://dev_user:******@rabbit:5672/tgvhost" 1 channels> connection closed

在跟踪之前,客户端似乎关闭了与rabbit的连接:

2020-03-20 09:45:23.855 [info] <0.639.0> accepting AMQP connection <0.639.0> (172.30.0.5:40902 -> 172.30.0.3:5672)
rabbit_1            | 2020-03-20 09:45:23.870 [info] <0.639.0> connection <0.639.0> (172.30.0.5:40902 -> 172.30.0.3:5672): user 'dev_user' authenticated and granted access to vhost 'tgvhost'
rabbit_1            | 2020-03-20 09:45:23.917 [info] <0.639.0> closing AMQP connection <0.639.0> (172.30.0.5:40902 -> 172.30.0.3:5672, vhost: 'tgvhost', user: 'dev_user')

如果我从Rabbit MQ aio-pika tutorial尝试RPC实现,一切都很好。我不确定这是一个bug还是我这边的一些错误配置,但我使用了这个兔子设置和pika(不是aio)和nameko框架,没有任何问题。不,我想迁移到异步quart框架,所以我需要使用带有aio pika的RPC

码头工人 RabbitMQ 3.7.5 爱奥皮卡6.6.0 Python 3.6


Tags: pydevlibusrlocalservicerpcconnection

热门问题