为什么基于 Telerik 的应用程序在一段时间后会失去与远程 SQL Server 的连接?

Why does my Telerik-based application lose its connection to a remote SQL Server after some time?

提问人:Dominique 提问时间:11/17/2023 最后编辑:Dominique 更新时间:11/17/2023 访问量:22

问:

我正在为基于 Telerik 技术并连接到远程 SQL Server 的 C# 应用程序提供支持。

使用连接字符串进行连接设置,如下所示:

"Data Source=10.131.53.7;Initial Catalog=DB_name;User ID=User;Password=pwd1234"

(不用担心弱密码:出于安全原因,信息是乱码)。

一切正常,但一段时间(±30 分钟)后,我收到一个异常,提到由于连接断开,无法检索查询结果。异常消息提到了无法访问的远程服务器的名称,并且该名称为空:

无法访问主机 '' 上的数据库服务器。

我的印象是存在通信问题,以这样的方式关闭与 SQL Server 的连接,以至于我的应用程序现在认为 SQL Server 的名称为空。

有谁知道这是怎么回事?

使用以下方法仍可访问计算机:ping

Prompt>ping 10.131.53.7

Pinging 10.131.53.7 with 32 bytes of data:
Reply from 10.131.53.7: bytes=32 time=29ms TTL=123
Reply from 10.131.53.7: bytes=32 time=22ms TTL=123
Reply from 10.131.53.7: bytes=32 time=28ms TTL=123
Reply from 10.131.53.7: bytes=32 time=22ms TTL=123

Ping statistics for 10.131.53.7:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 22ms, Maximum = 29ms, Average = 25ms

我相信我的应用程序和SQL Server之间的通信是基于TCP的,因此这个问题上有相应的标签。

供您参考,以下是完整的异常消息:

2023-11-17 08:37:53.5162 |ProductClient.Communications.Server通信 |数据库数据更改事件(更改)期间的异常
--- Telerik.OpenAccess.Exceptions.DataStoreException:无法访问主机“”上的数据库服务器。
错误详细信息:执行查询时出错:
Telerik.OpenAccess.RT.sql Exception:从服务器接收结果时发生传输级错误。(提供程序:会话提供程序,错误:19 - 物理连接不可用)
System.Data.SqlClient.SqlException:从服务器接收结果时发生传输级错误。(提供程序:会话提供程序,错误:19 - 物理连接不可用)

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action'1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource'1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at OpenAccessRuntime.CommandWrapper.ExecuteReader(CommandBehavior behavior)
at Telerik.OpenAccess.Runtime.Logging.LoggingDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.CommandImp.ExecuteReader()
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery(Nullable'1 commandTimeout)
--- End of inner exception stack trace ---
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.PreparedStatementImp.executeQuery(Nullable'1 commandTimeout)
at OpenAccessRuntime.Relational.conn.PooledPreparedStatement.executeQuery(Nullable'1 commandTimeout)
at OpenAccessRuntime.Relational.fetch.FetchResultImp.Execute()

SQL:
SELECT a.[voa_class] COL1, a.[AlarmId] COL2, ... FROM [Vehicles] WHERE a.[Id] = ?

Telerik.OpenAccess.RT.sql.SQLException: A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)
System.Data.SqlClient.SqlException: A transport-level error has occurred when receiving results from the server. (provider: Session Provider, error: 19 - Physical connection is not usable)

C# SQL-Server TCP Telerik

评论


答: 暂无答案