File tree Expand file tree Collapse file tree
sdk/servicebus/azure-servicebus/azure/servicebus/_pyamqp Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ def __init__(
100100 self ._is_closed = False
101101 self ._on_link_state_change = kwargs .get ("on_link_state_change" )
102102 self ._on_attach = kwargs .get ("on_attach" )
103- self ._error = None
103+ self ._error : Optional [ AMQPLinkError ] = None
104104
105105 async def __aenter__ (self ) -> "Link" :
106106 await self .attach ()
@@ -244,6 +244,11 @@ async def _incoming_detach(self, frame) -> None:
244244 self ._error = error_cls (condition = frame [2 ][0 ], description = frame [2 ][1 ], info = frame [2 ][2 ])
245245 await self ._set_state (LinkState .ERROR )
246246 else :
247+ if self .state != LinkState .DETACH_SENT :
248+ # Handle the case of when the remote side detaches without sending an error.
249+ # We should detach as per the spec but then retry connecting
250+ self ._error = AMQPLinkError (condition = ErrorCondition .UnknownError ,
251+ description = "Link detached unexpectedly." , retryable = True )
247252 await self ._set_state (LinkState .DETACHED )
248253
249254 async def attach (self ) -> None :
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ def __init__(
9696 self ._is_closed = False
9797 self ._on_link_state_change = kwargs .get ("on_link_state_change" )
9898 self ._on_attach = kwargs .get ("on_attach" )
99- self ._error = None
99+ self ._error : Optional [ AMQPLinkError ] = None
100100
101101 def __enter__ (self ) -> "Link" :
102102 self .attach ()
@@ -239,6 +239,11 @@ def _incoming_detach(self, frame) -> None:
239239 self ._error = error_cls (condition = frame [2 ][0 ], description = frame [2 ][1 ], info = frame [2 ][2 ])
240240 self ._set_state (LinkState .ERROR )
241241 else :
242+ if self .state != LinkState .DETACH_SENT :
243+ # Handle the case of when the remote side detaches without sending an error.
244+ # We should detach as per the spec but then retry connecting
245+ self ._error = AMQPLinkError (condition = ErrorCondition .UnknownError ,
246+ description = "Link detached unexpectedly." , retryable = True )
242247 self ._set_state (LinkState .DETACHED )
243248
244249 def attach (self ) -> None :
You can’t perform that action at this time.
0 commit comments