Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lukebakken opened this issue Dec 18, 2024 · 1 comment
Open
Assignees
Labels
Milestone

Comments

@lukebakken
Copy link
Contributor

lukebakken commented Dec 18, 2024

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)

@lukebakken lukebakken added the bug label Dec 18, 2024
@lukebakken lukebakken self-assigned this Dec 18, 2024
@lukebakken lukebakken added this to the 7.1.0 milestone Dec 18, 2024
@ZajacPiotr98
Copy link

I think passing already cancelled cancellation token will trigger exception already on the await _rpcSemaphore.WaitAsync(k.CancellationToken). The problem occurs when it's passed to the Connection.

Any exception thrown from the HandleCommandAsync method of AsyncRpcContinuation is causing closing the Connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants