Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.37k stars 4.78k forks source link

Microsoft.Azure.ServiceBus.ServiceBusException: 'sender9' is closed #26097

Closed onlywithlad closed 1 year ago

onlywithlad commented 2 years ago

Library name and version

Microsoft.Azure.ServiceBus 5.1.3

Query/Question

Hi Team,

We are having application in dot net core and hosted on fargate container. This application continuously listen to queue on one service bus. On receiving any message it sends that message to another queue of same service bus. To send a message we are creating MessageSender using queue path at the start of the application itself. Also we are using AMQPWebSockets as transport type. But during this we are experiencing intermittently exception as Microsoft.Azure.ServiceBus.ServiceBusException: 'sender9' is closed. Also on very next attempt using service bus retry it gets successfully send to that queue. We are not doing any reset or any explicit retry for this.

Exception : Microsoft.Azure.ServiceBus.ServiceBusException: 'sender9' is closed\n at Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList1 messageList)\\n at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation, TimeSpan operationTimeout)\n at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func1 operation, TimeSpan operationTimeout)\\n at Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList1 messageList)\n at ManagedSubscriber.Core.ServiceBusOperations.Complete(Message auditMessage, ServiceBusEntites serviceBusEntites, Message retrievedMessage, MessageProcessingReport messageProcessingReport)

Service bus package : Microsoft.Azure.ServiceBus Version : 5.1.3

AMQP package : Microsoft.Azure.Amqp version : 2.4.11

Dot net core : 3.1

Kindly guide us on the same.

Environment

Dot net core 3.1

ghost commented 2 years ago

Thank you for your feedback. This has been routed to the support team for assistance.

SaurabhSharma-MSFT commented 2 years ago

@onlywithlad It seems that the sender application took time to send the message and client instance is closed in between. I see that you are trying to use the older version (5.1.3) of SDK. I recommend you update to the latest version (5.2.0) and check this behavior in your environment. Additionally, you can start capturing Azure SDK logs if you are not doing it currently. Please refer to this document for details. Also, as you mentioned this is issue is happening intermittently, you may need to get it investigated through a Support ticket. Please let me know if you have any questions.

Thanks Saurabh

SaurabhSharma-MSFT commented 2 years ago

@onlywithlad Please let me know if you have any questions. Thanks.

onlywithlad commented 2 years ago

HI @SaurabhSharma-MSFT thank you for your guidance! But even after upgrading to latest version, issue is occurring randomly. And to capture azure sdk logs we are looking for steps to reproduce the issue. Otherwise as our application is continuously running application it will exhaust the space.

onlywithlad commented 2 years ago

HI @SaurabhSharma-MSFT we observed one more behavior. whenever we receive sender closed exception we are able to see one more error that is - "Microsoft.Azure.ServiceBus.ServiceBusException: The connection was inactive for more than the allowed 60000 milliseconds and is closed by container '9a467ca2-d058-4484-8c39-99e4842d3555'". As our application is continuous running application we are creating senders at the start of application only. we are not closing or recreating inbetween.

deivydas321 commented 2 years ago

Having the same error on Asp.Net Core 5.

Azure.Messaging.ServiceBus.ServiceBusException: 'sender179' is closed (GeneralError) at Azure.Messaging.ServiceBus.Amqp.AmqpSender.SendBatchInternalAsync(IEnumerable1 messages, TimeSpan timeout, CancellationToken cancellationToken) at Azure.Messaging.ServiceBus.Amqp.AmqpSender.<>c.<b__18_0>d.MoveNext() --- End of stack trace from previous location --- at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.<>c20`1.<b20_0>d.MoveNext() --- End of stack trace from previous location --- at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.RunOperation[T1,TResult](Func4 operation, T1 t1, TransportConnectionScope scope, CancellationToken cancellationToken) at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.RunOperation[T1,TResult](Func4 operation, T1 t1, TransportConnectionScope scope, CancellationToken cancellationToken) at Azure.Messaging.ServiceBus.ServiceBusRetryPolicy.RunOperation[T1](Func4 operation, T1 t1, TransportConnectionScope scope, CancellationToken cancellationToken) at Azure.Messaging.ServiceBus.Amqp.AmqpSender.SendBatchAsync(ServiceBusMessageBatch messageBatch, CancellationToken cancellationToken) at Azure.Messaging.ServiceBus.ServiceBusSender.SendMessagesAsync(ServiceBusMessageBatch messageBatch, CancellationToken cancellationToken)

SaurabhSharma-MSFT commented 2 years ago

@onlywithlad

"Microsoft.Azure.ServiceBus.ServiceBusException: The connection was inactive for more than the allowed 60000 milliseconds and is closed by container '9a467ca2-d058-4484-8c39-99e4842d3555'". I don't think this is an issue as Azure network has a timeout value of 1 min. If a connection is idle for 1 minute, then that connection will be closed. Please refer a link to see more details.

onlywithlad commented 2 years ago

Hi @SaurabhSharma-MSFT

is there any way to handle this connection idle scenario in code? As this is getting logged as an Error and we fear that it should not cause any message loss.

also is it related to OperationTimeout property of MessageSender class?

onlywithlad commented 2 years ago

HI @SaurabhSharma-MSFT is there a way we can check if connection is idle or not? and in case of idle or sender closed issue how can we make it active again?

ghost commented 2 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @shankarsama, @DorothySun216.

Issue Details
### Library name and version Microsoft.Azure.ServiceBus 5.1.3 ### Query/Question Hi Team, We are having application in dot net core and hosted on fargate container. This application continuously listen to queue on one service bus. On receiving any message it sends that message to another queue of same service bus. To send a message we are creating MessageSender using queue path at the start of the application itself. Also we are using AMQPWebSockets as transport type. But during this we are experiencing intermittently exception as Microsoft.Azure.ServiceBus.ServiceBusException: 'sender9' is closed. Also on very next attempt using service bus retry it gets successfully send to that queue. We are not doing any reset or any explicit retry for this. Exception : Microsoft.Azure.ServiceBus.ServiceBusException: 'sender9' is closed\\n at Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList`1 messageList)\\n at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)\\n at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)\\n at Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList`1 messageList)\\n at ManagedSubscriber.Core.ServiceBusOperations.Complete(Message auditMessage, ServiceBusEntites serviceBusEntites, Message retrievedMessage, MessageProcessingReport messageProcessingReport) Service bus package : Microsoft.Azure.ServiceBus Version : 5.1.3 AMQP package : Microsoft.Azure.Amqp version : 2.4.11 Dot net core : 3.1 Kindly guide us on the same. ### Environment Dot net core 3.1
Author: onlywithlad
Assignees: SaurabhSharma-MSFT
Labels: `Service Bus`, `Service Attention`, `Client`, `customer-reported`, `question`, `needs-team-attention`
Milestone: -
jsquire commented 1 year ago

Hi @onlywithlad. The Microsoft.Azure.ServiceBus library has been deprecated and is only receiving critical security and bug fixes. Unfortunately, this means that feature requests such as adding the ability to recover from an idle connection closing are not under consideration. It is recommended that applications using Microsoft.Azure.ServiceBus migrate to the current library, Azure.Messaging.ServiceBus which is under active development.

github-actions[bot] commented 1 year ago

Hi @onlywithlad. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.