Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dd185209 opened this issue Jun 11, 2024 · 6 comments
Open

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

dd185209 opened this issue Jun 11, 2024 · 6 comments

Comments

@dd185209
Copy link

dd185209 commented Jun 11, 2024

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
Copy link
Contributor

This could be a duplicate of #594.

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

@drsnyder
Copy link

Also confirmed that 9.4.1 does not reconnect after a rabbit restart but 8.2.1 does. In my testing, the application gets blocked on this line waiting for the __connection_close_event to be set.

@mosquito
Copy link
Owner

@drsnyder did you try to upgrade to the latest release?

@drsnyder
Copy link

drsnyder commented Dec 17, 2024

Yes, I tried upgrading. Release 9.4.2 also does not work.

@mosquito
Copy link
Owner

Current version is https://pypi.org/project/aio-pika/9.5.4/

@drsnyder
Copy link

@mosquito, thanks for getting back to me so fast. Sorry, 9.5.4 doesn't work either. It appears to be reconnecting but the consumer call backs are not receiving messages. Similar to the OP, I get:

Unexpected connection close from remote "amqp://<user>:******@localhost:5672//?reconnect_interval=10&fail_fast=0", Connection.Close(reply_code=320, reply_text="CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'")
NoneType: None
Connection attempt to "amqp://<user>:******@localhost:5672//?reconnect_interval=10&fail_fast=0" failed: Server connection unexpectedly closed. Read 0 bytes but 1 bytes expected. Reconnecting after 10 seconds.
Connection attempt to "amqp://<user>:******@localhost:5672//?reconnect_interval=10&fail_fast=0" failed: Server connection unexpectedly closed. Read 0 bytes but 1 bytes expected. Reconnecting after 10 seconds.
Connection attempt to "amqp://<user>:******@localhost:5672//?reconnect_interval=10&fail_fast=0" failed: Server connection unexpectedly closed. Read 0 bytes but 1 bytes expected. Reconnecting after 10 seconds.
Connection attempt to "amqp://<user>:******@localhost:5672//?reconnect_interval=10&fail_fast=0" failed: Server connection unexpectedly closed. Read 0 bytes but 1 bytes expected. Reconnecting after 10 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants