diff --git a/sdk/servicebus/Microsoft.Azure.ServiceBus/src/Amqp/AmqpExceptionHelper.cs b/sdk/servicebus/Microsoft.Azure.ServiceBus/src/Amqp/AmqpExceptionHelper.cs index 62b7f7ecdff06..11ad3313de3f9 100644 --- a/sdk/servicebus/Microsoft.Azure.ServiceBus/src/Amqp/AmqpExceptionHelper.cs +++ b/sdk/servicebus/Microsoft.Azure.ServiceBus/src/Amqp/AmqpExceptionHelper.cs @@ -215,6 +215,9 @@ public static Exception GetClientException(Exception exception, string reference case TimeoutException _: return new ServiceBusTimeoutException(message, aggregateException); + case InvalidOperationException ex when ex.Message.IndexOf("connection is closing", StringComparison.OrdinalIgnoreCase) != -1: + return new ServiceBusException(true, aggregateException); + case InvalidOperationException _ when connectionError: return new ServiceBusCommunicationException(message, aggregateException); } diff --git a/sdk/servicebus/Microsoft.Azure.ServiceBus/src/Core/MessageReceiver.cs b/sdk/servicebus/Microsoft.Azure.ServiceBus/src/Core/MessageReceiver.cs index 965db40e31c13..fb674e55ddbf8 100644 --- a/sdk/servicebus/Microsoft.Azure.ServiceBus/src/Core/MessageReceiver.cs +++ b/sdk/servicebus/Microsoft.Azure.ServiceBus/src/Core/MessageReceiver.cs @@ -1486,7 +1486,7 @@ async Task DisposeMessagesAsync(IEnumerable lockTokens, Outcome outcome) throw new MessageLockLostException(Resources.MessageLockLost); } - + throw AmqpExceptionHelper.GetClientException(exception); } }