环境:
- .Net
.NET Core SDKs installed:
3.1.409 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.15 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.15 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
- Microsoft.Data.SqlClient: 1.13
- SQL Server: 10.50.1600.1 (2008 R2 RTM)
问题表现
在通过 .Net 程序连接数据库查询时, 连接超时后断开, 并报如下错误:
Application startup exception: System.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 35 - An internal exception was caught)
---> System.IO.IOException: Unable to write data to the transport connection: Connection reset by peer.
---> System.Net.Sockets.SocketException: Connection reset by peer.
问题原因: 未知
解决方法: 升级到 SP3 (10.50.6000.34)
从 https://www.microsoft.com/en-us/download/details.aspx?id=44271 下载对应版本的 SP3 安装包, 双击安装, 重启电脑后可以解决。
其他信息:
- 如果上面加粗部分是 provider: SSL Provider 可能通过在连接字符串中添加
TrustServerCertificate=true
可解决 - 其他类似问题参考: