Skip to content

Cancelling ModelSendAsync can close the connection when it shouldn't #1750

@lukebakken

Description

@lukebakken

Describe the bug

Reported here: #1720 (comment)

Reproduction steps

  • Pass cancellation token to BasicConsumeAsync that will close in the future.
  • Notice that the connection is closed:
    CloseReason: AMQP close-reason, initiated by Library, code=541, text='A task was canceled.', classId=0, methodId=0, exception=System.Threading.Tasks.TaskCanceledException: A task was canceled.
    at RabbitMQ.Client.Impl.BasicConsumeAsyncRpcContinuation.HandleCommandAsync(IncomingCommand cmd)
    at RabbitMQ.Client.Impl.Channel.HandleCommandAsync(IncomingCommand cmd, CancellationToken cancellationToken)
    at RabbitMQ.Client.Framing.Connection.ProcessFrameAsync(InboundFrame frame, CancellationToken cancellationToken)
    at RabbitMQ.Client.Framing.Connection.ReceiveLoopAsync(CancellationToken mainLoopCancellationToken)
    at RabbitMQ.Client.Framing.Connection.MainLoop()
    

Expected behavior

Connection should not close in this case.

Additional context

#1720 (comment)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions