function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

The underlying connection was closed: An unexpected error occurred on a receive.

I've gotten maybe 10 of these from an integration we have that simply pulls Contract records from production.  Iv'e had these one and off (maybe like 1 every 10 days) for a couple months, but this morning I've gotten just a landslide.    Using reflector, the endpoint I'm pointing to currently (in the app config) is: "".  


Is there something change that I missed or something like that with Salesforce connectivity?  Thanks. 


Machine: CSMSIIS1

Date: 2/19/2010 8:12:40 AM

Type: System.Net.WebException

Assembly: CSG.MSI.Contracts.SFDCWrapper, CSG.MSI.Contracts, Version=, Culture=neutral, PublicKeyToken=null

Codebase: file:///C:/Program Files/Metastorm BPM/Engine/dotnetbin/CSG.MSI.Contracts.DLL

Message: The underlying connection was closed: An unexpected error occurred on a receive.

Source: CSG.MSI.Contracts

Stacktrace:    at CSG.MSI.Contracts.SFDCWrapper.ExecuteSOQL(String soql) in C:\Documents and Settings\bryang\Desktop\CSG.MSI.Contracts\CSG.MSI.Contracts\DAL\Util\SFDCWrapper.vb:line 127

   at CSG.MSI.Contracts.SFDCContractMapper.SelectMultipleInternal(String SOQL) in C:\Documents and Settings\bryang\Desktop\CSG.MSI.Contracts\CSG.MSI.Contracts\DAL\Data\Mappers\SFDCContractMapper.vb:line 77

   at CSG.MSI.Contracts.SFDCContractMapper.Select(String id) in C:\Documents and Settings\bryang\Desktop\CSG.MSI.Contracts\CSG.MSI.Contracts\DAL\Data\Mappers\SFDCContractMapper.vb:line 25

   at CSG.MSI.Contracts.ContractStatus.GetContractStatus(String contractid) in C:\Documents and Settings\bryang\Desktop\CSG.MSI.Contracts\CSG.MSI.Contracts\BLL\ContractStatus.vb:line 6

   at CSG.MSI.Contracts.Contract.GetContractStatus(String contractId) in C:\Documents and Settings\bryang\Desktop\CSG.MSI.Contracts\CSG.MSI.Contracts\Contracts.vb:line 6

Exception Custom Data: 

SOQL Statement = SELECT Id, AccountId, OwnerId, Status, Opportunity__c, Contract_Status__c, Contract_Begin_Date__c, Contract_Type__c  FROM Contract  WHERE Id = 'XXXXXXX'  


Any ideas would be most welcome.  Thanks. 


Are you by any chance tying to run this code in a loop or something ?


I found I got this error when I tried to connect to the API too many times in succession, it appears that it goes in to some sort of defensive mode and blocks the request when you hit the service too hard, of course the block is to simply drop the connection.


I know it's an old thread, but I'm seeing exactly the same behavior described by "AlwaysConfused"

We are hitting about 5 different salesforce instances (different customers) and sometimes SF would just start dropping (closing) our connections. We've looked at the TCP messages them self - it's definately SF closing on us. Again, after it starts no customers can do anything (which tells me that it's not instance problem, it's API exaustion. 

And after 15-30 minutes it will stop being defensive and start aception (not dropping) the connections.

Anybody faced something like this?


we are also receiving error - "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server" when calling SOAP API from C#. these errors happen only during peak times when there are large number of calls are being made concurrently.

any update on how you fixed it ?
Sukjin YoonSukjin Yoon