Skip to main content
edited title
Link
Matthew Dresser
  • 6.1k
  • 2
  • 29
  • 77

Could SocketException be caused by CloudSearchRetryPolicy?

Source Link
Matthew Dresser
  • 6.1k
  • 2
  • 29
  • 77

SocketException caused by CloudSearchRetryPolicy

I'm investigating an issue where we are seeing SocketExceptions and socket handle leaks. Using Sitecore 8.2 rev 107614, in Azure using Azure Search as the search provider.

Drilling down to one of the exceptions, I see the message

An unhandled exception occurred. Error while rendering view: '/Views/Layouts/Layout.cshtml' (model: 'Sitecore.Mvc.Presentation.RenderingModel, Sitecore.Mvc'). An unhandled exception occurred. An unhandled exception occurred. An error occurred while sending the request. Unable to connect to the remote server An attempt was made to access a socket in a way forbidden by its access permissions

The exception type is

System.Net.Sockets.SocketException

and the Failed method is

Sitecore.ContentSearch.Azure.Http.RetryDelegatingHandler+<>c__DisplayClass2_0.b__0

So I'm wondering if this is related to how the search service client is configured as I see there are some re-tryer configuration settings (left at default, I believe)

<searchServiceClient type="Sitecore.ContentSearch.Azure.Http.SearchServiceClient, Sitecore.ContentSearch.Azure">
  <param ref="contentSearch/httpClientFactory" desc="clientFactory"/>
  <param type="Sitecore.ContentSearch.Azure.Http.CloudSearchRetryPolicy, Sitecore.ContentSearch.Azure" desc="retryPolicy">
    <DetectionStrategy type="Sitecore.ContentSearch.Azure.Http.CloudSearchTransientDetectionStrategy, Sitecore.ContentSearch.Azure"/>
    <RetryStrategy type="Sitecore.ContentSearch.Azure.Http.CloudSearchExponentialRetryStrategy, Sitecore.ContentSearch.Azure">
      <Exponent>1.5</Exponent>
      <MaxRetryCount>10</MaxRetryCount>
      <MinDelayInterval>00:00:00.5</MinDelayInterval>
      <MaxDelayInterval>00:00:10</MaxDelayInterval>
    </RetryStrategy>
  </param>
  <managementOperationsTimeout>00:01:00</managementOperationsTimeout>
</searchServiceClient>

Question(s)

When does the "re-tryer" come into play, could be it during unavailability of the search service? Is there any documentation about the re-tryer, or does someone know how I might modify these settings to avoid the SocketException issue I am seeing? (I can guess what MaxReTryCount, MinDelayInterval and MaxDelayInterval do, but not sure what the Exponent property is for?).