gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 13:18:35 25 4
gpt4 key购买 nike

我已经在 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

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

关于asp.net - Azure网站有时无法连接到SQL Azure数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23290720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com