RabbitMQ pika.exceptions.ConnectionClosed

杀马特。学长 韩版系。学妹 提交于 2019-12-03 13:55:09

This is because you are keeping the main thread waiting, and because of this pika cannot handle incoming messages; in this case it cannot respond to the heartbeat until the subprocess is done. This causes RabbitMQ to think that the client is dead and forces a disconnection.

If you want this to work with heartbeats (which is recommend) you need to periodically call connection.process_data_events. This can be done by adding a loop that checks if the thread is done, and every 30s or so call process_data_events until the thread is done.

Look add this https://github.com/mosquito/aio-pika

It's an asynchio wrapper and if u understand the concept behind asynchron very easy to use :)

it seems that it is not connecting to RabbitMQ at 127.0.0.1:5672 -- are you sure RabbitMQ is running and listening on 127.0.0.1:5672?

for linux (debian) users

You can check if RabbitMQ is installed by typing this command.

sudo service rabbitmq-server status

If you get back a response, that means it it installed. Check if it is running or not?

to start rabbitMQ serve type

sudo service rabbitmq-server start

to restart rabbitMq use this command

sudo service rabbitmq-server restart

No response means that you don't have Rabbitmq installed. install it by typing the following commands.

sudo apt-get update

sudo apt-get -y upgrade

sudo apt-get install rabbitmq-server

And then start the server by typing the start command above.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!