asp.net mvc - call to web api endpoint from same mvc application is timing out -


i have rest service implemented using asp.net web api. reasons needed call 1 of endpoints within same application , report time took response endpoint. added normal mvc controller action below

public class healthmonitoringcontroller : controller {     //     // get: /healthmonitoring/      public contentresult getresponsetime(string id)     {         var startdatetime = datetime.now;         var httpwebrequest = (httpwebrequest) webrequest.create(<<rest endpoint>>);         httpwebrequest.method = webrequestmethods.http.get;         httpwebrequest.accept = "application/json;charset=utf-8";         httpwebrequest.headers.add("accept-language", "en-gb");         httpwebrequest.getresponse();         var duration = (int) datetime.now.subtract(startdatetime).totalmilliseconds;         return content(string.format("response time:{0}", duration.tostring(cultureinfo.invariantculture)));     } } 

as can see above, i'm using httpwebrequest class invoke rest endpoint hosted in same website. record time before , after request made , return time.

problem

we have got monitoring tool calls on route recorded response time. monitoring tool calls route every 1 minute. works time , httpwebrequest.getresponse() starts timing out no obvious reason.there nothing in event log , in iis logs

at point if restart application pool, thing start working again time , stops after time.

while above thing not working, if make rest endpoint call myself manually, works. there no issue rest endpoint.

i'm clueless @ point. appreciated.

first off, "health check" same domain pretty irrelevant; , checking latency way trivial. understanding have problems , looking way track issue, use trace log or elmah, not repetitive ping endpoint.

that being said, if want check if api working can instantiate controller , call method directly. test access portion without layering issue potential socket trouble (webrequest/webclient/* libraries). though you're not getting in delay, mentioned, delay useless in context anyways.

var api = new apicontroller(); try {   api.somemethod("param1", "param2");   return content("works"); } catch (exception ex) {   return content("failed: " + ex.message); } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -