1

I'm quite a beginner in using HTTP Request,

I have an automated task that updates the attendance of 6000 employees every hour. When I was testing my API in my local, it succeeded with minimum 40 seconds. Once I have deployed it, it gives me an operation time-out.

I wish to increase my Request Time-out to at least a minute.

I have used this code :

[HttpPost("autoAttendanceUpdate")]
public bool AUTO_AttendanceUpdate([FromBody] AttendanceProcessorFilters filter)
{
     HttpClient httpClient = new HttpClient();
     httpClient.Timeout = TimeSpan.FromMinutes(1);
     _attendanceProcessorRepository.AUTO_attendanceUpdate(filter); // AUTO_attendanceUpdate contains the logic
}

But I think I have used httpClient wrong.

I don't know if I should modify AUTO_attendanceUpdate or if there are other solutions that can help me. AS much as possible I don't want any other methods to be affected so adjusting web config is not an option. TIA

bish-cuit
  • 31
  • 1
  • 3
  • This doesn't seem related to `HttpClient` at all - you're creating it but not using it to make any requests. Are you asking how to change the timeout for requests to ASP.NET Core rather than from ASP.NET Core to another service (as you might use `HttpClient` for)? – ProgrammingLlama Jun 01 '21 at 07:19
  • Yes, I want to change the timeout for requests to ASP.NET Core as I cannot find anything as of the moment – bish-cuit Jun 01 '21 at 07:21
  • Where was the timeout exception thrown? On your client when it was submitting a request? Or did the server aka the ASP.NET Core pipeline threw a time out? If it was the former the timeout needs to be configured on the clients making the requests. If in doubt post the exact exception with its complete stacktrace here. – ckuri Jun 01 '21 at 07:25
  • If you're hosting on IIS, see [here](https://stackoverflow.com/questions/43097433/request-timeout-from-asp-net-core-app-on-iis). – ProgrammingLlama Jun 01 '21 at 07:27
  • Most likely you have a TLS issue. TLS is used for authentication before the HTTP Request is sent. If TLS fails there is never a Request sent. You must have a timeout when a response does not get received. Since the request is never sent you never get a response. – jdweng Jun 01 '21 at 09:47

0 Answers0