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

%3CLINGO-SUB%20id%3D%22lingo-sub-1652579%22%20slang%3D%22en-US%22%3ESharePoint%20CSOM%20-%20Unable%20to%20read%20data%20from%20the%20transport%20connection%3A%20An%20existing%20connection%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1652579%22%20slang%3D%22en-US%22%3E%3CP%3EWhile%20doing%20some%20not%20heavy%20operations%20(like%20add%20admins%2C%20add%20content%20type)%20in%20SharePoint%20CSOM%20we%20are%20getting%20below%20error%20which%20is%20not%20reproducible%20but%20comes%20intermittently.%20Mainly%20different%20article%20pointing%20to%20client%20context.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CP%3E%3CEM%3E%22IOException*Unable%20to%20read%20data%20from%20the%20transport%20connection%3A%20An%20existing%20connection%20was%20forcibly%20closed%20by%20the%20remote%20host.%22%3C%2FEM%3E%3C%2FP%3E%3CP%3Esearched%20and%20found%20some%20articles%20as%20below.%20but%20still%20not%20getting%20clear%20solution.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F59771733%2Fsystem-net-sockets-socketexception-an-existing-connection-was-forcibly-closed%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fstackoverflow.com%2Fquestions%2F59771733%2Fsystem-net-sockets-socketexception-an-existing-connection-was-forcibly-closed%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%20Keval%3C%2FP%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1652579%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Visitor

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.

https://stackoverflow.com/questions/59771733/system-net-sockets-socketexception-an-existing-connecti...

 

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 ;) )