'The connection was inactive for more than the allowed 60000 milliseconds and is closed by container

I have an azure function that sends a message to the service bus queue. Since a recent deployment, I see an exception occurring frequently: The connection was inactive for more than the allowed 60000 milliseconds and is closed by container.

enter image description here

I looked into this GitHub post: https://github.com/Azure/azure-service-bus-java/issues/280 it says this is a warning. Is there a way to increase this timeout? Or any suggestions on how to resolve this? Here is my code:


namespace Repositories.ServiceBusQueue
{
    public class MembershipServiceBusRepository : IMembershipServiceBusRepository
    {
        private readonly QueueClient _queueClient;
        public MembershipServiceBusRepository(string serviceBusNamespacePrefix, string queueName)
        {
            var msiTokenProvider = TokenProvider.CreateManagedIdentityTokenProvider();
            _queueClient = new QueueClient($"https://{serviceBusNamespacePrefix}.servicebus.windows.net", queueName, msiTokenProvider);
        }
        public async Task SendMembership(GroupMembership groupMembership, string sentFrom = "")
        {
            if (groupMembership.SyncJobPartitionKey == null) { throw new ArgumentNullException("SyncJobPartitionKey must be set."); }
            if (groupMembership.SyncJobRowKey == null) { throw new ArgumentNullException("SyncJobRowKey must be set."); }
            foreach (var message in groupMembership.Split().Select(x => new Message
            {
                Body = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(x)),
                SessionId = groupMembership.RunId.ToString(),
                ContentType = "application/json",
                Label = sentFrom
            }))
            {
                await _queueClient.SendAsync(message);
            }
        }
    }
}



Solution 1:[1]

This could be due to deadlock in the thread pool, please check if you are calling an async method from a sync method.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gustavo Nogueira