I have jQuery AJAX call which request for summary count from WEB API Services. The WEB API process the request and calls a stored procedure (sql server) passing the request parameters. The stored procedure takes longer time (more than 10 minutes to process the request. If the Stored Procedure takes more than 10 minutes the jQuery AJAX call is reporting an unknown error with status code 12002 or 12152(these errors relates to connectivity issue) but the Web Server receives the result back from the stored procedure after 10 minutes. The problem is occuring on browser is IE8.0 , IE9.0, firefox but chrome is receiving the response even if it wait beyond 10 minutes. Is there any solutions to keep the communication alive between the server and the client. I have tried changing the connection request header from ajax to "close","open","keep-alive" nothing works. Pls help me out.
Java Script Code.
$.ajax({
type: "post",
url: URLPrefix + 'api/querydispatcher/summary',
data: s,
success: function (data) {
window.clearInterval(int);
$('#wait').hide();
$('#CancelSummary').hide();
$('#backgroundmodal').hide();
$("#tResultTotals").slideDown('slow');
DeserializeJSon(eval(data));
if (!CancelSummaryRequest) {
CancelSummaryRequest = true;
$('#DownloadDetailedReport').show();
}
else {
$('#tResultTotals').hide();
}
},
$('#wait').hide();
$('#CancelSummary').hide();
$('#backgroundmodal').hide();
error_Dialog(request.responseText);
}
});
}
Server Side (WEB API) code.
[WebInvoke(UriTemplate = "summary", Method = "POST")]
public List<QueryResult> GetSummaryReport_Queue(JsonValue SummaryXML)
{
MyContext db = new MyContext();
DateTime StartTime = DateTime.Now;
string sumXML = SummaryXML["XMLJson"].ToString().Replace(@"\", "").Replace(@"""", "");
//These are two codes created by JSon @ the end of the String that need to be trim off.
sumXML = sumXML.Replace("u000du000a", "");
List<QueryResult> results = null;
XElement xxml = XElement.Parse(sumXML);
string ReportID = xxml.Descendants("ReportId").FirstOrDefault().Value;
string err = "";
try
{
results = db.fnReportResult(sumXML).ToList();
}
catch (Exception e)
{
err = e.Message + " : "+(e.InnerException!=null?e.InnerException.Message : "");
throw e;
}
finally {
///--- Record Audit Info.
double RunningTime = DateTime.Now.Subtract(StartTime).TotalMilliseconds;
string parameters = "ApplicationType:Query_Dispatcher" + "||User:" + SummaryXML["UserId"].ToString().Replace(@"\", "").Replace(@"""", "") +
"||Session:" + SummaryXML["Session"].ToString().Replace(@"\", "").Replace(@"""", "") +
"||Running Time:" + RunningTime.ToString() + "||Request Type:Summary Report" +
"||Report ID:" + ReportID +
"||Error:" + err;
Audit SaveAudit = new Audit();
SaveAudit.WriteAudit("Query_Builder", parameters);
//####-Recording Audit Info
}
return results;
}