Describe the bug
I often get this error even I updated the nuget package to latest
(regarding similar issue -> https://github.com/Azure/azure-service-bus-dotnet/issues/639)
Exception or Stack Trace
Microsoft.Azure.ServiceBus.ServiceBusException: The operation was canceled.
---> System.OperationCanceledException: The operation was canceled. at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
at Microsoft.Azure.Amqp.AsyncResult.End[TAsyncResult](IAsyncResult result
at Microsoft.Azure.Amqp.ReceivingAmqpLink.EndReceiveMessages(IAsyncResult result, IEnumerable1& messages
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.ExceptionServices.ExceptionDispatchInfo.Throw(
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.d__86.MoveNext()
--- End of inner exception stack trace --- at Microsoft.Azure.ServiceBus.Core.MessageReceiver.d__86.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<>c__DisplayClass64_0.<b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
at Microsoft.Azure.ServiceBus.RetryPolicy.d__19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
at Microsoft.Azure.ServiceBus.RetryPolicy.d__19.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.d__64.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.d__62.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw(
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task
at Microsoft.Azure.ServiceBus.MessageReceivePump.d__11.MoveNext()
To Reproduce
I can not reproduce it.
Thank you for opening this issue! We are routing it to the appropriate team for follow up.
CC: @ramya-rao-a, @AlexGhiondea
@kurtzeborn In this case, it would be @jsquire and @AlexGhiondea :)
Any update @jsquire and @AlexGhiondea ?
@ocengiz0 from looking at the callstack there isn't sufficient information to try and figure out the root cause. Would you happen to have a repro that we can look at?
The only way I can reproduce is that while in a long debug session, I receive this error in my ExceptionReceivedEvent method in which implemented to MessageHandlerOptions
_subscriptionClient is ISubscriptionClient
```cs
var messageHandlerOptions = new MessageHandlerOptions(ExceptionReceivedHandler)
{
MaxConcurrentCalls = 1,
AutoComplete = false
};
_subscriptionClient.RegisterMessageHandler(ProcessMessagesAsync, messageHandlerOptions);
private Task ExceptionReceivedHandler(ExceptionReceivedEventArgs exceptionReceivedEventArgs)
{
var context = exceptionReceivedEventArgs.ExceptionReceivedContext;
var exception = exceptionReceivedEventArgs.Exception;
_logger.LogError(exception, $"Message handler encountered an exception: {exception.Message}, Endpoint: {context.Endpoint}, Entity Path: {context.EntityPath}, Executing Action: {context.Action}");
return Task.CompletedTask;
}
We are getting this exception too in our production. However its difficult to repro locally
messages = await eventHubReceiver.ReceiveAsync(64);
Our callstack is
System.OperationCanceledException: The operation was canceled. at Microsoft.Azure.Amqp.AsyncResult.EndTAsyncResult at Microsoft.Azure.Amqp.ReceivingAmqpLink.EndReceiveMessages(IAsyncResult result, IEnumerable1& messages) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task`1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at Microsoft.Azure.EventHubs.Amqp.AmqpPartitionReceiver.OnReceiveAsync(Int32 maxMessageCount, TimeSpan waitTime) at Microsoft.Azure.EventHubs.Amqp.AmqpPartitionReceiver.OnReceiveAsync(Int32 maxMessageCount, TimeSpan waitTime) at Microsoft.Azure.EventHubs.PartitionReceiver.ReceiveAsync(Int32 maxMessageCount, TimeSpan waitTime)
Get similar error and new stacktrace:
Microsoft.Azure.ServiceBus.ServiceBusException: The operation was canceled. ---> System.OperationCanceledException: The operation was canceled.
at Microsoft.Azure.Amqp.ExceptionDispatcher.Throw(Exception exception)
at Microsoft.Azure.Amqp.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.Azure.Amqp.ReceivingAmqpLink.ReceiveAsyncResult.End(IAsyncResult result, IEnumerable`1& messages)
at Microsoft.Azure.Amqp.ReceivingAmqpLink.EndReceiveMessages(IAsyncResult result, IEnumerable`1& messages)
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<>c__DisplayClass86_1.<OnReceiveAsync>b__1(IAsyncResult a) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 1037
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.OnReceiveAsync(Int32 maxMessageCount, TimeSpan serverWaitTime) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 1035
--- End of inner exception stack trace ---
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.OnReceiveAsync(Int32 maxMessageCount, TimeSpan serverWaitTime) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 1068
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.<>c__DisplayClass64_0.<<ReceiveAsync>b__0>d.MoveNext() in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 375
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\RetryPolicy.cs:line 85
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\RetryPolicy.cs:line 108
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.ReceiveAsync(Int32 maxMessageCount, TimeSpan operationTimeout) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 380
at Microsoft.Azure.ServiceBus.Core.MessageReceiver.ReceiveAsync(TimeSpan operationTimeout) in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\Core\MessageReceiver.cs:line 323
at Microsoft.Azure.ServiceBus.MessageReceivePump.MessagePumpTaskAsync() in C:\source\azure-service-bus-dotnet\src\Microsoft.Azure.ServiceBus\MessageReceivePump.cs:line 64
/cc @nemakam @binzywu
Hello, any update?
@nemakam, @binzywu, @kurtzeborn @jsquire and @AlexGhiondea
I started a long running instance which captures the state when we run into this issue. Waiting for the bug to reproduce..
@ocengiz0 I a getting a similar issue #9543
I get into this state when message processing is taking a long time. I am getting Task canceled and service bus timeout exception. And getting these exceptions in bulk. How to handle these exceptions ?
I have the same #16975
Most helpful comment
@ocengiz0 I a getting a similar issue #9543
I get into this state when message processing is taking a long time. I am getting Task canceled and service bus timeout exception. And getting these exceptions in bulk. How to handle these exceptions ?