Hello,
I have a custom-code import application which writes incoming new records to CRM or updates if the record already exists. The first thing the import does is query the ContactSet using the IOrganisationService to create a list of existing contacts (a scaled-down custom class (called “ContactData”) holding just the crmid and emailaddress). This list is then used to compare incoming records to see if they already exist as Contacts in CRM.
using (var context = new XrmServiceContext(service))
{
contactdataList = (from a in context.CreateQuery("contact")
select new ContactData
{
CrmId = (Guid)a["contactid"],
Email = (string)a["emailaddress1"]
}
}
This has been working fine every night for months without any errors or changes until last night when the error below was logged when executing the code above.
exception 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.GZipWrapperStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.ServiceModel.Channels.PreReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.HttpInput.WebResponseHttpInput.WebResponseInputStream.Read(Byte[] buffer, Int32 offset, Int32 count)
NOTE: If I reduce the contact query by filtering on e.g. just one email address, the import runs successfully.
Does anyone know what could be causing this error? Have I hit some kind of threshold for this type of query where the number of contacts has surpassed?
There are 337K Contacts in total.
Any suggestions gratefully received.
Thanks,
- Seamus