SharePoint CSOM - Unable to read data from the transport connection: An existing connection


While doing some not heavy operations (like add admins, add content type) in SharePoint CSOM we are getting below error which is not reproducible but comes intermittently. Mainly different article pointing to client context.


"IOException*Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."

searched and found some articles as below. but still not getting clear solution.


Thanks, Keval

8 Replies
Any luck finding a solution? I am running in to the same issue.
Update your .net framework version to at least 4.7.2. This will enable TLS 1.2 which is necessary for the data transfer.
I have an application running .NET 4.8 which is showing the same behavoir.
I'm extracting files from SharePoint per iteration. It runs for about 10 iterations, then I get the same exception as mentioned.

@DonHeuvelman Do you get the problem if you slow the process down?  Maybe put some sleep operations in at the end of each iteration.  If not TLS related, perhaps SP is throttling you?

@dscore Yeah, sort of, we put the whole request in a loop and append a sleep to it.

So we can request multiple times at once, about 10 or 11. Whenever a following request fails with the given exception, you have to wait until the previous connection is closed and this takes a few seconds, we just wait in the thread and continu after a few seconds (we try again until it succeeds)
Elegant? Not at all.. but its sufficient enough for our goals. (if it looks stupid but it works.... it's not stupid .. well not really but you get the point ;) )