I have a backgroundservice built in .Net Core that executes a SQL Server database procedure as follows:
public int ExecuteProcedure(string connectionString, string sql, Dictionary<string, object> parameters = null)
{
var response = -99;
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
// Create a SqlCommand, and identify it as a stored procedure.
using (SqlCommand sqlCommand = new SqlCommand(sql, connection))
{
sqlCommand.CommandType = CommandType.StoredProcedure;
if(parameters != null)
SetParameters(sqlCommand, parameters);
response = sqlCommand.ExecuteNonQuery();
}
connection.Close();
}
return response;
}
When I run the bakcgroundservice on my local machine it runs without problems but when I use docker and kubernetes I get the following error:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)
I have consulted in several places but all the answers I find are about restarting Visual Studio or IIS which does not apply in my case due to having the application in kubernetes
I would greatly appreciate your help.