A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error:0

Viewed 1006

I am getting the below exception while making the database call from an IIS deployed application Asp.Net Core 3.1 API.

A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The wait operation timed out.)

It workes as expected If I restart the application in IIS. But this error starts again in some days. So I need a permanent solution and root cause to this issue.

ConnectionString:

"Data Source=ABC.PQR.XYZ.IT.SQL;Initial Catalog=DBName;User ID=User;Password=***",

Note:

The same application is working as expected on different servers and pointing to a different database.

2 Answers

With limited information provided, I am assuming that you are using Data.SqlClient. Try adding the following to the connection string.

"Data Source=ABC.PQR.GCXYZ.IT.SQL;Initial Catalog=DBName;User ID=User;Password=***;TrustServerCertificate=true",

Since it works for a few days with no issues, it might be due to the application occupying the allowable connection limits like a bad recursion that exponentiate the calls to the database.

There were some connectivity issues between my server machine and database server, I have solved the issue by adding MultiSubnetFailover=Trueto the connection string.

Related