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

Viewed 4903

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.

1 Answers

The error is presented by the image used when building the docker container.

I was using the image: mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim but when I changed it to: mcr.microsoft.com/dotnet/core/runtime:3.1-bionic worked fine.

From what I have been consulting it seems that the image that was failing me has a version of the TLS that is not compatible to make the successful connection with SqlServer

Related