AJAX请求中Azure SQL中的间歇性连接超时

The*_*own 11 sql-server asp.net azure azure-sql-database

我一直在寻找在Azure ASP.NET网站的AJAX调用上间歇性地发生的这个错误,今天我终于在我们的日志中发现了它.我怀疑锁是阻止操作,但看起来它尝试连接到Azure SQL数据库失败了.

这是异常消息:

Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. 
This failure occurred while attempting to connect to the routing destination.
The duration spent while attempting to connect to the original server was -
[Pre-Login] initialization=28; handshake=43; [Login] initialization=0; authentication=0; [Post-Login] complete=2;  
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的连接字符串:

Server=tcp:<server>,1433;Database=<database>;User ID=<user>;Password=<password>;Trusted_Connection=False;Encrypt=True;Connection Timeout=30
Run Code Online (Sandbox Code Playgroud)

网站和Azure SQL数据库都位于同一区域.数据库的比例是标准 - S0,Azure网站是标准 - 小实例.

有没有人遇到过这个问题?

dgi*_*ard 1

听起来问题出在客户端到互联网的连接上。如果您在客户端 JavaScript 中进行 Ajax 调用,则 Web 应用程序和数据库是否位于同一区域并不重要(至少就性能而言)。非常慢的连接将调用超时。

由于这是间歇性的,我建议在 JavaScript 中捕获此错误并允许提示客户端重试保存。

  • 失败的连接发生在 Web 服务器(例如 Azure Web App)和数据库服务器 (Azure SQL) 之间。我相信我的问题是我在 Azure SQL 中使用的实例大小,即 S0(我在上面添加了注释 @AKS)。不过还是谢谢你的建议!我应该在解决问题后发布我的解决方案。 (2认同)