SQL中的间歇性连接超时

SQL中的间歇性连接超时

本文介绍了AJAX请求上的Azure SQL中的间歇性连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找此错误,该错误在对Azure ASP.NET网站的AJAX调用中间歇发生,今天,我终于在我们的日志中捕获了该错误.我怀疑一个锁正在阻止该操作,但是它似乎在尝试连接到Azure SQL数据库时失败.

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.

以下是异常消息:

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

网站和Azure SQL数据库都在同一区域中.数据库的规模为Standard-S0,Azure网站为Standard-Small实例.

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.

你们有遇到这个问题吗?

Have any of you ran into this issue?

推荐答案

听起来问题出在从客户端到Internet的连接中.如果要使用客户端JavaScript进行Ajax调用,则Web应用程序和数据库是否位于同一区域并不重要(至少就性能而言).连接速度非常慢会导致超时.

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.

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

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

这篇关于AJAX请求上的Azure SQL中的间歇性连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 16:25