Azure Service Bus - Receive Message fails with following exception

Gowtham, Karthik 21 Reputation points
2022-09-01T13:29:11.03+00:00

I have implemented Azure Service Bus, and it fails with following exception. This happens randomly, not always. Send operation works fine always, only receive operation fails sometimes. Any leads on why it is failing in few instances?

System.Threading.Tasks.TaskCanceledException: A task was canceled.
at Microsoft.Azure.Amqp.AsyncResult.EndTAsyncResult
at Microsoft.Azure.Amqp.ReceivingAmqpLink.EndReceiveMessages(IAsyncResult result, IEnumerable1& messages) at Microsoft.Azure.Amqp.ReceivingAmqpLink.<>c.<ReceiveMessagesAsync>b__27_1(IAsyncResult r) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) \--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Messaging.ServiceBus.Amqp.AmqpReceiver.<ReceiveMessagesAsyncInternal>d__39.MoveNext() \--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Azure.Messaging.ServiceBus.Amqp.AmqpReceiver.<>c.<<ReceiveMessagesAsync>b__38_0>d.MoveNext() \--- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Threading.Tasks.ValueTask1.get_Result()
at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1.ConfiguredValueTaskAwaiter.GetResult() at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<RunOperation>d__212.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<RunOperation>d__21`2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Messaging.ServiceBus.Amqp.AmqpReceiver.<ReceiveMessagesAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Azure.Messaging.ServiceBus.ServiceBusReceiver.<ReceiveMessagesAsync>d__39.MoveNext()

Thanks,
Karthik

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
542 questions
{count} votes

Accepted answer
  1. JananiRamesh-MSFT 20,826 Reputation points
    2022-09-04T14:49:27.1+00:00

    Hi @Gowtham, Karthik Thanks for reaching out. From the description it looks like the error is transient. Then, most likely it's some kind of connectivity issue between your application and one of it's dependencies. Error The Task was canceled indicates an async task that was cancelled, or most likely timed out.

    you may be able to extend some of the implicit timeout periods or try to catch and handle these Exception gracefully.

    let me know incase of further queries, I would be happy to assist you.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful