加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – Azure网站有时无法连接到SQL Azure数据库

发布时间:2020-12-16 03:29:26 所属栏目:asp.Net 来源:网络整理
导读:我一直在Azure测试一个网站大约一个月(免费试用),现在我已经订阅了现收现付版.当我参加免费试用时,我绝对没有连接问题.现在,我再次部署到一个新的网站,该网站使用与前一个相同的设置(缩放模式等)在按需付费订阅中创建.但是,现在当我导航到我的网站时,它有时
我一直在Azure测试一个网站大约一个月(免费试用),现在我已经订阅了现收现付版.当我参加免费试用时,我绝对没有连接问题.现在,我再次部署到一个新的网站,该网站使用与前一个相同的设置(缩放模式等)在按需付费订阅中创建.但是,现在当我导航到我的网站时,它有时无法连接到我的数据库:

Server Error in '/' Application.
A connection attempt failed because the connected party did not properly respond after
a period of time,or established connection failed because connected host has failed to
respond
Description: An unhandled exception occurred during the execution of the current web
request. Please review the stack trace for more information about the error and where
it originated in the code.

Exception Details: System.ComponentModel.Win32Exception: A connection attempt failed 
because the connected party did not properly respond after a period of time,or
established connection failed because connected host has failed to respond

Source Error:

An unhandled exception was generated during the execution of the current web request.
Information regarding the origin and location of the exception can be identified using
the exception stack trace below.

Stack Trace:


[Win32Exception (0x80004005): A connection attempt failed because the connected party 
did not properly respond after a period of time,or established connection failed 
because connected host has failed to respond]

[SqlException (0x80131904): A network-related or instance-specific error occurred 
while establishing a connection to SQL Server. The server was not found or was not 
accessible. Verify that the instance name is correct and that SQL Server is configured
to allow remote connections. (provider: TCP Provider,error: 0 - A connection attempt
failed because the connected party did not properly respond after a period of time,or
established connection failed because connected host has failed to respond.)

我尝试刷新页面并连接.几分钟后,当我再次尝试时,我有时会再次遇到同样的错误,但有时候不会.我在免费试用模式下从未遇到过单一连接问题.为什么会发生这种情况?如何防止此问题?

解决方法

预计在云环境中会出现瞬态错误.假设数据库调用失败,如果您在几毫秒后重试,则现在可以使用相同的调用.为了保护您免受这些错误的影响,您需要实现重试逻辑.如果您使用Entity Framework 6,那么您很幸运,因为它已经在 http://msdn.microsoft.com/en-US/data/dn456835中出现了
这是一个关于如何实现这个的快速视频: http://www.azurerocks.com/0_oaw-merMw

您还可以使用企业库瞬态故障处理应用程序块:http://msdn.microsoft.com/en-us/library/hh680934(v=pandp.50).aspx

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读