Azure Service Bus Exception : Cannot allocate more handles. The maximum number of handles is 4999

Devendra 1 Reputation point
2022-09-14T06:07:55.04+00:00

I have n numbers of azure functions getting invoked and sending messages to topics. Meanwhile I get below exception:
Cannot allocate more handles. The maximum number of handles is 4999. (QuotaExceeded), StackTrace : at Azure.Messaging.ServiceBus.Amqp.AmqpConnectionScope.CreateSendingLinkAsync(String entityPath, String identifier, AmqpConnection connection, TimeSpan timeout, CancellationToken cancellationToken)
at Azure.Messaging.ServiceBus.Amqp.AmqpConnectionScope.OpenSenderLinkAsync(String entityPath, String identifier, TimeSpan timeout, CancellationToken cancellationToken)
at Azure.Messaging.ServiceBus.Amqp.AmqpSender.CreateLinkAndEnsureSenderStateAsync(TimeSpan timeout, CancellationToken cancellationToken)
at Microsoft.Azure.Amqp.FaultTolerantAmqpObject1.OnCreateAsync(TimeSpan timeout) at Microsoft.Azure.Amqp.Singleton1.GetOrCreateAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton1.GetOrCreateAsync(TimeSpan timeout) at Azure.Messaging.ServiceBus.Amqp.AmqpSender.CreateMessageBatchInternalAsync(CreateMessageBatchOptions options, TimeSpan timeout) at Azure.Messaging.ServiceBus.Amqp.AmqpSender.<>c.<<CreateMessageBatchAsync>b__16_0>d.MoveNext() \--- End of stack trace from previous location where exception was thrown --- at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.RunOperation[T1,TResult](Func4 operation, T1 t1, TransportConnectionScope scope, CancellationToken cancellationToken)
at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.RunOperationT1,TResult
at Azure.Messaging.ServiceBus.Amqp.AmqpSender.CreateMessageBatchAsync(CreateMessageBatchOptions options, CancellationToken cancellationToken)
at Azure.Messaging.ServiceBus.ServiceBusSender.CreateMessageBatchAsync(CreateMessageBatchOptions options, CancellationToken cancellationToken)

What steps should I take up to address this issue? Please help.

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
625 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,000 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 27,181 Reputation points
    2022-09-14T13:45:39.48+00:00

    Hi @Devendra Thanks for reaching out. This Error (Cannot allocate more handles. The maximum number of handles is 4999. (QuotaExceeded)) essentially means the client is creating unbounded number of senders or receivers on the same connection. Each MessagingFactory represents a single connection to Service Bus and each sender/receiver created from the MessagingFactory creates a AMQP Session and link. The number of AMQP links on the connection is restricted to 5000. Exceeding this limit generates above error.

    For more information please refer: https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-quotas

    This documentation https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-amqp-protocol-guide will be helpful to understand how the AMPQ links works.

    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.

    3 people found this answer helpful.

Your answer

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