title: OperationCanceledException when sending to Service Bus
body: <p>I am getting OperationCanceledException when I am sending a message to a topic queue (I am running my code from within an Azure function).
  The version I am using is:  "WindowsAzure.ServiceBus": "4.1.1" (latest)
  and I am getting this exception when I am doing load testing which means many messages are being sent in this service bus (which contains several topics).
  I was told to use a retry mechanism as:</p>
  
  <pre><code>client.RetryPolicy = new RetryExponential(minBackoff: TimeSpan.FromSeconds(0.1),
                                              maxBackoff: TimeSpan.FromSeconds(30),
                                              maxRetryCount: 3);
  </code></pre>
  
  <p>But I thought this is already done by default, doesn't it?</p>
  
  <p>Would appropriate your help here - Why am I getting this exception and what can I do to resolve this?</p>
  
  <p>Here is the exception:</p>
  
  <pre><code>Exception System.OperationCanceledException: The operation cannot be performed because the entity has been closed or aborted. ---&gt; System.ServiceModel.CommunicationObjectAbortedException: Internal Server Error: The server did not provide a meaningful reply; this might be caused by a premature session shutdown. TrackingId:88386cb1-a4e6-42e2-a8e1-bad3a2403329, Timestamp:6/6/2017 7:55:23 AM
     at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.&lt;&gt;c.&lt;GetAsyncSteps&gt;b__9_3(RequestAsyncResult thisPtr, IAsyncResult r)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
  --- End of stack trace from previous location where exception was thrown ---
     at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.RequestAsyncResult.&lt;&gt;c__DisplayClass8_1.&lt;GetAsyncSteps&gt;b__4(RequestAsyncResult thisPtr, IAsyncResult r)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
  --- End of stack trace from previous location where exception was thrown ---
     at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.EndRequest(IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.&lt;&gt;c.&lt;GetAsyncSteps&gt;b__9_3(RequestAsyncResult thisPtr, IAsyncResult r)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
  --- End of stack trace from previous location where exception was thrown ---
     at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.&lt;&gt;c.&lt;GetAsyncSteps&gt;b__18_3(TIteratorAsyncResult thisPtr, IAsyncResult a)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
  --- End of stack trace from previous location where exception was thrown ---
     at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
     --- End of inner exception stack trace ---
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
  --- End of stack trace from previous location where exception was thrown ---
     at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
     at Microsoft.ServiceBus.Messaging.MessageSender.OnSend(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
     at Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
  </code></pre>