Ale*_*era 2 sql-server kubernetes asp.net-core
我在 .Net Core 中内置了一个后台服务,它执行 SQL Server 数据库过程,如下所示:
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;
}
Run Code Online (Sandbox Code Playgroud)
当我在本地计算机上运行 bakcgroundservice 时,它运行没有问题,但是当我使用 docker 和 kubernetes 时,出现以下错误:
与服务器成功建立连接,但在登录前握手期间发生错误。(提供者:TCP 提供者,错误:35 - 捕获内部异常)
我在几个地方咨询过,但我找到的所有答案都是关于重新启动 Visual Studio 或 IIS,这不适用于我的情况,因为应用程序位于 kubernetes 中
我将非常感谢你的帮助。
该错误是由构建 docker 容器时使用的映像呈现的。
我正在使用图像:mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim但是当我将其更改为:mcr.microsoft.com/dotnet/core/runtime:3.1-bionic工作正常。
从我一直在咨询的内容来看,让我失败的图像似乎有一个 TLS 版本,该版本与 SqlServer 成功连接不兼容
| 归档时间: |
|
| 查看次数: |
6632 次 |
| 最近记录: |