Share via

Large numbers of Timeout Exceptions from Service Bus

Neil Sorensen 20 Reputation points
2026-04-22T20:24:33.5+00:00

We're starting to use Service Bus, and we've seen some large spikes of System.TimeoutExceptions. For example, we have one application that's consuming from ~10 subscriptions, and each instance recorded 411 System.TimeoutExceptions with a message saying The operation did not complete within the allocated time 00:00:05 for object receiver###. (ServiceTimeout) over the course of ~3 seconds.

I understand that networking is messy, and temporary interruptions will happen. My concern is that because of the number of exceptions that we're getting, we're getting alerts for issues that are already resolved by the time we can look. Is there a way to limit or supress these exceptions so our automated alerts won't be triggered? The stack trace for the exception doesn't include any of our code.

Azure Service Bus
Azure Service Bus

An Azure service that provides cloud messaging as a service and hybrid integration.

0 comments No comments

Answer accepted by question author

  1. Rakesh Mishra 8,420 Reputation points Microsoft External Staff Moderator
    2026-04-22T21:38:32.52+00:00

    Hello Neil,

    Since you mentioned that "The stack trace for the exception doesn't include any of our code", it's highly likely you are using the background message processor provided by the SDK (such as ServiceBusProcessor in the Azure.Messaging.ServiceBus package, or RegisterMessageHandler in the older Microsoft.Azure.ServiceBus package) rather than a manual ReceiveMessageAsync loop.

    When using these event-driven processors, the SDK continuously polls the broker for new messages in the background. If a polling request waits for the duration of the configured timeout and doesn't receive a message (or experiences a brief network hiccup), it throws a TimeoutException. The SDK safely catches this internally, passes it to the configured error handler, and automatically retries.

    To prevent these transient polling timeouts from triggering your automated alerts, you should intercept and filter them out inside the central error handler callback that you provide to the SDK.

    Here is how you can suppress these specific exceptions based on the SDK you are using:

    1. If using the newer Azure.Messaging.ServiceBus SDK:
      When configuring your ServiceBusProcessor, you register a ProcessErrorAsync handler. Inside this handler, you can check if the exception is a transient timeout and safely ignore it.
         processor.ProcessErrorAsync += ErrorHandler;
         Task ErrorHandler(ProcessErrorEventArgs args)
         {
             // Filter out transient timeouts so they don't trigger alerts
             if (args.Exception is ServiceBusException sbEx && sbEx.Reason == ServiceBusFailureReason.ServiceTimeout)
             {
                 // Transient – log as Trace/Debug instead of Error, or ignore completely
                 return Task.CompletedTask;
             }
             
             if (args.Exception is TimeoutException)
             {
                 return Task.CompletedTask;
             }
             // Log actual critical errors to your alerting/APM system here
             // ...
             
             return Task.CompletedTask;
         }
      
    2. If using the older Microsoft.Azure.ServiceBus SDK:
      When calling RegisterMessageHandler, you configure a MessageHandlerOptions object containing an ExceptionReceivedHandler.
         var options = new MessageHandlerOptions(ExceptionReceivedHandler);
         subscriptionClient.RegisterMessageHandler(ProcessMessagesAsync, options);
         Task ExceptionReceivedHandler(ExceptionReceivedEventArgs args)
         {
             // Filter out timeout exceptions
             if (args.Exception is ServiceBusTimeoutException || args.Exception is TimeoutException)
             {
                 // Suppress alert
                 return Task.CompletedTask;
             }
             // Log actual critical errors
             // ...
             return Task.CompletedTask;
         }
      
    3. Check your Timeout Configuration:
      The exception specifically mentions an allocated time of 00:00:05 (5 seconds). By default, Service Bus clients usually have a 60-second timeout. It's highly probable that someone explicitly configured the TryTimeout (new SDK) or OperationTimeout (old SDK) to 5 seconds. Increasing this timeout closer to the default of 60 seconds will drastically reduce the sheer volume of these exceptions, as the processor won't "give up" and log an error quite so aggressively during quiet periods. Reference Links:

    Hope this helps clear out the noise in your monitoring rules and do let me know in comments if any further questions.

    Note: This response is drafted with the help of AI systems.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.