Skip to content

Can't seem to capture the ConnectionClosed exception #126

Open
@silverdaz

Description

@silverdaz

I'm using the simple consumer example and I get messages from local message broker.

Then I artificially restart the broker.

The frame arrives, gets decoded and the ConnectionClosed exception is created.
However, the code tries to close the connection (and send a CloseOk frame, which won't succeed), but the exceptions are suppressed. The ConnectionClosed itself is passed on, but I don't see where it is raised again.

I'm only getting the following output and no error raised.

Unexpected connection close from remote "amqp://username:******@localhost:5672/%2F", Connection.Close(reply_code=320, reply_text="CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'")
NoneType: None

Note that this is just a print statement, not the exception itself. (I find the NoneType: None suspiciously buggy). After that, no more messages are consumed.

I'd like to capture the ConnectionClosed (and potientially other related ones) and retry the connection (with an exponential backoff) when the broker is restarted.

Am I miss-using the package or am I missing something in the asyncio-loop catching-exception business?
I've tried to put some encompassing try/except but I can't seem to catch the ConnectionClosed exception (although I see it in the logs, when I turn on the debug output. Where does it get swallowed, and why?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions