Skip to content

Commit

Permalink
Fix a channel issue against a connection already closed
Browse files Browse the repository at this point in the history
In some possible case a connection can be closed (network issue, etc...) and
then channels reset to None, in this case if the client use
the on_inbound_method then we can facing a TypeError exception.

The `on_inbound_method` is not enough safer and then this method can
try to get channel from a none existing object.

In this case we need to raise a `RecoverableConnectionError` to allow client
to re-connect properly and re-init objects properly.
  • Loading branch information
4383 authored and auvipy committed Sep 11, 2019
1 parent 7e671b5 commit 86cb254
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions amqp/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,11 @@ def blocking_read(self, timeout=None):
return self.on_inbound_frame(frame)

def on_inbound_method(self, channel_id, method_sig, payload, content):
return self.channels[channel_id].dispatch_method(
method_sig, payload, content,
)
if self.channels is not None:
return self.channels[channel_id].dispatch_method(
method_sig, payload, content,
)
raise RecoverableConnectionError('Connection already closed')

def close(self, reply_code=0, reply_text='', method_sig=(0, 0),
argsig='BsBB'):
Expand Down

0 comments on commit 86cb254

Please sign in to comment.