Linux .netcore 连接 Windows SqlServer2008R2 报错
程序员文章站
2024-03-20 23:14:58
...
在Linux使用.netcore 3.1 连接 Windows 安装的SqlServer2008R2时报了很奇怪的错误。
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 read data from the transport connection: Connection reset by peer.
---> System.Net.Sockets.SocketException (104): Connection reset by peer
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Data.SqlClient.SNI.SNIPacket.ReadFromStream(Stream stream)
at System.Data.SqlClient.SNI.SNITCPHandle.Receive(SNIPacket& packet, Int32 timeoutInMilliseconds)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at IoTCloud_MqttDataTransfer.SqlHelper.GetDataTakerBindInfo(String longAddr) in xx.cs:line 97
ClientConnectionId:5fc10d14-a569-4046-819e-afb962b0bbd3
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)
Save InfluxDB data: False
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)
同样的代码在windows使用vs调试时,连接数据库ok。
网上查资料,网友说可能是sqlserver版本问题,需要打补丁
SqlServer2012及更高版本可能没有这个问题。
我这里是SqlServer2008R2安装SP3补丁包后,就可以连接数据库正常了。
参考:
https://github.com/dotnet/runtime/issues/16528
https://github.com/dotnet/efcore/issues/5989
https://*.com/questions/38656090/connecting-to-sqlserver-from-net-core-on-ubuntu-visual-studio-code
上一篇: Java实现线性回归模型算法
推荐阅读
-
Linux .netcore 连接 Windows SqlServer2008R2 报错
-
putty连接linux报错---Network error:Connection refused 博客分类: Linux linuxputtyssh
-
putty连接linux报错---Network error:Connection refused 博客分类: Linux linuxputtyssh
-
Docker在Linux/Windows上运行NetCore文章系列
-
windows 远程桌面连接 kali linux
-
php-求助大神,在Windows下运行好的,放到linux下报错了
-
Linux主机无法连接Windows上的MySQL服务器解决方案
-
Windows和Linux系统下perl连接SQL Server数据库的方法
-
阿里云ECS Linux服务器外网无法连接MySQL解决方法(报错2003- Can't connect MySQL Server on 'x.x.x.x'(10038))
-
Windows下使用PuTTY连接Centos7、Linux系统目录结构、一些操作命令