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

时间:2022-10-14 21:01:06

I've been hunting for this error that occurs intermittently on an AJAX call to an Azure ASP.NET Website, and today I've finally caught it in our logs. I was suspecting a lock was blocking the operation, but it looks like it failed trying to connect to the Azure SQL database.

我一直在寻找在AJAX调用Azure ASP时间歇性出现的错误。NET网站,今天我终于在我们的日志中找到了。我怀疑锁阻塞了操作,但看起来它试图连接Azure SQL数据库失败了。

Here is the exception message:

这里有一个异常消息:

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;  

This is the connection string I am using:

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

Server=tcp:<server>,1433;Database=<database>;User ID=<user>;Password=<password>;Trusted_Connection=False;Encrypt=True;Connection Timeout=30

Both the website and the Azure SQL database are in the same region. The database's scale is Standard - S0, and the Azure Website is a Standard - Small instance.

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

Have any of you ran into this issue?

你们有人遇到过这个问题吗?

1 个解决方案

#1


1  

It sounds like the problem is in the connection from the client to the Internet. If you are making the Ajax call in client-side JavaScript, it doesn't matter (at least as far as performance goes) whether the web app and database are in the same region. A very slow connection will call a timeout.

听起来问题出在客户端到Internet的连接上。如果在客户端JavaScript中调用Ajax调用,那么web应用程序和数据库是否位于同一区域,这并不重要(至少在性能上是如此)。一个非常慢的连接会叫超时。

Since this is intermittent, I recommend catching this error in JavaScript and allowing prompting the client to retry the save.

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

#1


1  

It sounds like the problem is in the connection from the client to the Internet. If you are making the Ajax call in client-side JavaScript, it doesn't matter (at least as far as performance goes) whether the web app and database are in the same region. A very slow connection will call a timeout.

听起来问题出在客户端到Internet的连接上。如果在客户端JavaScript中调用Ajax调用,那么web应用程序和数据库是否位于同一区域,这并不重要(至少在性能上是如此)。一个非常慢的连接会叫超时。

Since this is intermittent, I recommend catching this error in JavaScript and allowing prompting the client to retry the save.

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