Azure / azure-amqp

AMQP C# library
Other
94 stars 70 forks source link

Only send Detach if the link has already sent or received an Attach frame #216

Closed bainian12345 closed 2 years ago

bainian12345 commented 2 years ago

When opening and attaching a link, an exception will cause the link to close. During this closing process, we should only send the Detach frame to remote if we have already sent or received an Attach frame. Otherwise, the remote party will have no idea about the existence of this link at the moment, and there will be no valid handle for this link on the remote session, so the remote session will not be able to handle this Detach frame.

For example, this behavior can be currently reproduced if the below exception is thrown from AmqpLink.AttachLink(AmqpLink link)

            if (this.links.ContainsKey(link.Name))
            {
                throw new AmqpException(AmqpErrorCode.ResourceLocked, AmqpResources.GetString(AmqpResources.AmqpLinkNameInUse, link.Name, this.LocalChannel));
            }
xinchen10 commented 2 years ago

Updated the AmqpObject state machine and this is not true anymore.