'Message Lost Lock and Connection Inactive in Service Bus

I have the following the Azure Service Bus Trigger Function code:

[FunctionName("FunctionName")]
public async Task Run(ServiceBusTrigger("", Connection = "connectionString")] Message message, MessageReceiver messageReceiver, [DurableClient] IDurableOrchestrationClient starter)
{
    var person = JsonConvert.DeserializeObject<Person>(Encoding.UTF8.GetString(message.Body));
    await starter.StartNewAsync(nameof(OrchestratorFunction), person);
    await messageReceiver.CompleteAsync(message.SystemProperties.LockToken);
}

On running this, I see the following 2 errors:

enter image description here

AND

enter image description here

What am I missing?



Solution 1:[1]

The lock lost exception indicates that when you call "completeasync" the lock is already expired. Which means that the receiver is taking longer to process the message than the lock duration. You can try increasing the lock duration up to the maximum of 5 minutes to see if the frequency of those lock lost exceptions reduces or dissapears.

The other exception just indicates that the service closed due connection due to inactivity but this is harmless, and the receiver will reconnect automatically after that.

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 Jdresc