Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intermittent Connection Timeout in Azure SQL on AJAX Request

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?

like image 430
TheJesterCrown Avatar asked Apr 24 '15 05:04

TheJesterCrown


1 Answers

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.

like image 139
dgiard Avatar answered Oct 05 '22 23:10

dgiard