我的应用程序连接到多个SQL Server实例(使用SMO和ADO.net),这些连接都已正确关闭(我正在使用),一个连接是用于表更改通知的SqlDependency。
部分应用程序与远程系统建立封装的 VPN 连接,这会导致所有网络资源(包括 SQL 实例)不可用。
处理这种情况的推荐方法是什么?网络\sql 断开连接频繁但可预测的情况。
我正在使用连接池,因此无法控制重新建立连接,如果我尝试打开连接(从池中检索可用连接),一旦我尝试使用它就会失败。 (因为未测试池连接以节省开销)。
My application connects to several SQL Server instances (Using SMO and ADO.net), these connections are all closed properly (I'm using Using), one connection is a SqlDependency for table change notification.
Part of the application establishes an encapsulated VPN connection to a remote system, this causes all network resources to be unavailable, including the SQL instances.
What would be recommended method of handling this scenario? Where a network\sql disconnect is frequent but predictable.
I'm using connection pooling so have no control over re-establishing a connection, if I attempt to open a connection (Which retrieves an available connection from the pool) it will fail as soon as I attempt to use it. (As pooled connections are not tested to save overhead).
发布评论
评论(1)
使用
NetworkChange
类对 IP 地址表更改做出反应,这表明值得再次尝试。当 VPN 连接和断开连接时,此类会通知您。当您检测到更改时,请使用SqlConnection.ClearAllPools
。您还应该研究 VPN 的替代方案,这些方案仍然允许您在远程连接时查看本地网络资源,例如 DirectAccess。
Use the
NetworkChange
class to react to IP address table changes that would indicate that is worth trying again. This class would notify you when the VPN connects and when it disconnects. When the you detect a change, clear all connection pools withSqlConnection.ClearAllPools
.You should also investigate alternatives to VPN that still allow you to see local network resources while connected remotely, like DirectAccess.