网络\SQL Server 不可用时挂起应用程序

发布于 2024-10-10 17:08:04 字数 276 浏览 0 评论 0 原文

我的应用程序连接到多个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).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荒岛晴空 2024-10-17 17:08:04

使用 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 with SqlConnection.ClearAllPools.

You should also investigate alternatives to VPN that still allow you to see local network resources while connected remotely, like DirectAccess.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文