Intermittent Connection Timeout in Azure SQL on AJAX Request

自作多情 提交于 2019-12-04 09:21:32

问题


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.

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.

Have any of you ran into this issue?


回答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.

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



来源:https://stackoverflow.com/questions/29839609/intermittent-connection-timeout-in-azure-sql-on-ajax-request

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!