-->

connection issue to azure cognitive search from as

2020-05-07 08:23发布

问题:

I have a asp.net mvc website developed in .NET framework 4.7. getting connection issue from hosted website. can you please help

An error occurred while sending the request. ---> 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

回答1:

I usually face this error while debugging, but if you deploy this it will disappear.
For debugging purpose, add following lines before calling external services.
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;



回答2:

it worked after adding the below lines

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls