title: Dynamics CRM Cause CommunicationException
body: <p>I am using MS Dynamics CRM api to get data (more then 5000 records) from it.</p>
  
  <p>I am using XML based query to get data</p>
  
  <pre><code>EntityCollection resultSet = _orgServiceProxy.RetrieveMultiple(new FetchExpression(query));
  </code></pre>
  
  <p>sometime time it works and most of the time it throws exception, from logs, I am getting this long exception.</p>
  
  <blockquote>
    <p>An error occurred while receiving the HTTP response to <a href="https://orgno.api.crm.dynamics.com/XRMServices/2011/Organization.svc" rel="nofollow">https://orgno.api.crm.dynamics.com/XRMServices/2011/Organization.svc</a>. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to <a href="https://orgno.api.crm.dynamics.com/XRMServices/2011/Organization.svc" rel="nofollow">https://orgno.api.crm.dynamics.com/XRMServices/2011/Organization.svc</a>. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead) --- End of inner exception stack trace --- at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace</p>
  </blockquote>
  
  <p>I don't know why this is happening?</p>