0

I have an async Call from MVC Controller to another WebAPI. This piece of code was working for 3-4 years, without issues. Now, we had to move the Code to a different server environment. The website keeps working for 24 hours, exactly after 24 hours, the async calls to the Web API, start returning task cancelled exception. An app pool refresh for the API solves the issue.

When the "task cancelled exception" comes up, the API doesnt log any incoming requests. But when i make a request from Postman, the API returns results and logs the call as well.

below is the HTTP Client that makes the call to the WebAPI

using (var client = new HttpClient())
{
  client.SetBearerToken(GetToken());
  using (var content = new MultipartFormDataContent())
  {
     var response = await client.PostAsync(uri, content);
     return response.Content.ReadAsAsync<T>().Result;
  }
}```

[![App Pool settings for API][1]][1]


 [1]: https://i.stack.imgur.com/2EIix.png
jothi
  • 332
  • 1
  • 5
  • 16
  • 1
    Please share your IIS app pool recycle settings. – mjwills Apr 30 '20 at 05:17
  • Is it possible that the bearer token is getting expired after 24 hours. Look into the GetToken() method call to understand how the token is being returned. If expired, get a new token generated and pass it on to the client. – TejSoft Apr 30 '20 at 12:18
  • 1
    Hows the status of current requests in IIS manager->worker processes->site->view current requests? It sounds like the application reach some limit for some reason.If you can't view current request ,please ensure IIS->health and diagnostic->request monitor has been installed. – Jokies Ding May 01 '20 at 07:53
  • @mjwills - https://i.stack.imgur.com/2EIix.png is the app pool setting for the API. It is the same for the web except that load User Profile is set to true for the MVC Web app. – jothi May 14 '20 at 10:45

0 Answers0