Ajax http 500 error Azure not on local -


when running ajax request error message:

failed load resource: server responded status of 500 (ok)

the problem server error not seem occur. when run application on local machine azure database don't error message. published azure application generates error. have done remote debugging , though browser display error server keeps handling request , minutes later finishes request. if there not server error.

the server needs 10 minutes finish request. believe has fact request long (because works on smaller databases). know azure has restrictions on cpu time on app service level free switched basic (no cpu time restrictions) should not problem. request sql intense (about 20k sql queries).

ajax call:

  $.ajax({   async: true,   cache: false,   type: "post",   url: foourl,   contenttype: 'application/json',   datatype: "json",   data: json.stringify(null),   success: function (error_message) {     $("#foobar").removeclass("loading");   },   error: function(jqxhr, textstatus, errorthrown) {   console.log(textstatus, errorthrown);   } }); 

controller:

  [authorize]   [requirehttpsattribute]   public class foocontroller : controller   {     private foobarmodel foobarmodel = new foobarmodel();      public actionresult updatefoobarmodel()     {       foobarmodel.updatemodel();       return json("success");     } 

there apparently idle timeout in azure described here. default value set 4 min , can configured 30 min if run application on vm. solved creating table in database stores current status of request.

table:

create table [dbo].[mytable] ( [updateno] int identity (1, 1) not null, [alldone]  bit default ((0)) not null, constraint [mytable$primarykey] primary key clustered ([updateno] asc) 

);

instead of calling method directly create task , returns id of update status row.

public actionresult updatefoobarmodel() {   int id = foobarmodel.startupupdate(); //creates status row    task.run(() => foobarmodel.updatemodel(id));   return json(id); }  public actionresult getupdatestatus(int updateno) {   bool status = foobarmodel.getupdatestatus(updateno);   return json(status); } 

ajax call:

function check_status(statusid) { $.ajax({   async: true,   cache: false,   type: "post",   url: getupdatestatusurl + "/?updateno=" + statusid,   contenttype: 'application/json',   datatype: "json",   success: function (statusdone) {     if (statusdone == true) {       console.log("update done!");       $("#foobar").removeclass("loading");     } else {       console.log("not done!")       settimeout(function () {         check_status(statusid);       }, 5000); //check every 5 seconds     }   },   error: function (jqxhr, textstatus, errorthrown) {     console.log(textstatus, errorthrown);   } }); 

}


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -