mosquito / aio-pika

AMQP 0.9 client designed for asyncio and humans.
https://aio-pika.readthedocs.org/
Apache License 2.0
1.18k stars 186 forks source link

Issue recreating connection to a queue after a connection problem #632

Open dd185209 opened 2 weeks ago

dd185209 commented 2 weeks ago

Hi my application is using aio-pika=9.4.1 to connect to a rabbitmq. I'm testing under docker environment and if I manually shutdown rabbit I see following log messages:

Unexpected connection close from remote "amqp://user:******@localhost:5672", Connection.Close(reply_code=320, reply_text="CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'")
NoneType: None
Connection attempt to "amqp://user:******@localhost" failed: Server connection unexpectedly closed. Read 0 bytes but 1 bytes expected. Reconnecting after 5 seconds.
Connection attempt to "amqp://user:******@localhost" failed: [WinError 1225] The remote computer refused the network connection. Reconnecting after 5 seconds.
Connection attempt to "amqp://user:******@localhost" failed: [WinError 1225] The remote computer refused the network connection. Reconnecting after 5 seconds.
Connection attempt to "amqp://user:******@localhost" failed: [WinError 1225] The remote computer refused the network connection. Reconnecting after 5 seconds.

but when rabbit restarts I see following errors:

Connection attempt to "amqp://user:******@localhost" failed: Server connection unexpectedly closed. Read 0 bytes but 1 bytes expected. Reconnecting after 5 seconds.
Connection attempt to "amqp://user:******@localhost" failed: Server connection unexpectedly closed. Read 0 bytes but 1 bytes expected. Reconnecting after 5 seconds.

then the application is successfully connecting to new instance (no more error where logged) but it's not true for the exchange and queue (there is no consumer). The application is now blocked whiting for new messages that never be read.

Using aio-pika==8.2.1 the application were working fine, I got similar error when the rabbitmq is down, but when it comes up again even the consumer is connected and messages are processed correctly.

Darsstar commented 1 week ago

This could be a duplicate of https://github.com/mosquito/aio-pika/issues/594.

How certain are you that there is a strong reference chain to the Channel or Queue?