question

YasharEbtehaj-4466 avatar image
0 Votes"
YasharEbtehaj-4466 asked YasharEbtehaj-4466 commented

Sharepoint intermittently resettin connection when using CSOM to search for document

As the title says, I'm using the CSOM dll's to search, archive, etc etc documents in SharePoint, but every so often the connection is being reset, this is the error that comes back:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> 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

I'm using an older version of .net 3.5.2, and reading around it could be a TLS issue (using older version), so I have applied the registry settings needed to fix this, and run wireshark, it shows it's using TLS1.2 for the connection, so I don't know what else could be the issue, any help would be appreciated!

Thanks

office-sharepoint-onlinesharepoint-dev
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @YasharEbtehaj-4466 ,
would you please provide us with an update on the status of your issue?

0 Votes 0 ·

1 Answer

RaytheonXie-MSFT avatar image
0 Votes"
RaytheonXie-MSFT answered YasharEbtehaj-4466 commented

Hi @YasharEbtehaj-4466 ,
.net 3.5.2 does now support TLS 1.2,but you don't need the registry changes.Try following steps:
Add imports:

 Imports System.Security.Authentication
 Imports System.Net

Add this to my code (C#):

 public const SslProtocols _Tls12 = (SslProtocols)0x00000C00;
 public const SecurityProtocolType Tls12 = (SecurityProtocolType)_Tls12;
 ServicePointManager.SecurityProtocol = Tls12

links for reference:
https://support.microsoft.com/en-us/topic/support-for-tls-system-default-versions-included-in-the-net-framework-3-5-1-on-windows-7-sp1-and-server-2008-r2-sp1-5ef38dda-8e6c-65dc-c395-62d2df58715a
https://support.microsoft.com/en-us/topic/support-for-tls-system-default-versions-included-in-the-net-framework-3-5-on-windows-8-1-and-windows-server-2012-r2-499ff5ef-a88a-128b-c639-ed038b7d2d5f


If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RaytheonXie-MSFT ,

The issue we have is that this is a problem for a customer of ours, and making a code change would incur some costs for them (they'd have a consultancy to do the installation, it's an app on Business Central), so that's a route we'd only take once we've exhausted all other options. Another issue is that it seems like we are using TLS1.2, the wireshark logs show the connection as TLS1.2 so even with the code change we're not sure if this would fix the issue.

I've got a support case open, but haven't had a response since I raised it 7 days ago (not sure if you'll be able to see it but it's case number 27003224).

Thanks

0 Votes 0 ·

Hi @YasharEbtehaj-4466 ,
Could you try to update .Net Framework to 4.6? Per my test the error occurs when the version lower than 4.6

0 Votes 0 ·

Hi @RaytheonXie-MSFT ,

We've updated the project to 4.6.1, but the issue still persists.

If it helps I can send over the wireshark logs?

Thanks

0 Votes 0 ·