1

I have a web API(service) whose target framework is .net core 2.0.

This service is calling a custom identity server 4 endpoint using HttpClient by using the 'using' statement. This call always works fine on the development/UAT server. But on all production servers, it fails intermittently and throws the following exception:

One or more errors occurred. (An error occurred while sending the request.) Exception: System.AggregateException: One or more errors occurred. (An error occurred while sending the request.) ---> System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: The operation timed out at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.Tasks.RendezvousAwaitable`1.GetResult() at System.Net.Http.WinHttpHandler.d__105.MoveNext() --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at System.Net.Http.HttpClient.d__58.MoveNext()
--- End of inner exception stack trace --- at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at Get(String a, String b)

I went through related stack-overflow posts, some suggested making HttpClient static as it might throw socket exhaustion error. But I am not getting that error either I am able to reproduce this issue on a development server. I created a console application and called this service 64k times, but still, it worked properly.

How to stop outbound HTTP connections from timing out

Asp.net Core HttpClient has many TIME_WAIT or CLOSE_WAIT connections

Can someone please tell me, what can be the reason for this intermittent error only on the production server or is there any way I can reproduce this issue on the dev server. I have tried by making many calls to service, but still unable to reproduce the error.

Thangadurai
  • 2,573
  • 26
  • 32
Purnima Naik
  • 2,393
  • 5
  • 17
  • 25
  • you can try adding a retry logic for this type of exception. – Aravind Dec 26 '19 at 10:57
  • But the user is trying continuously, it fails by throwing same exception only. – Purnima Naik Dec 26 '19 at 13:46
  • On production there is a different network ? Maybe the router ? Firewall ? Nat ? – Max Dec 26 '19 at 15:48
  • it could be a case of the existing instances are not able to take the load and hence you need to scale up or throttle requests to certain limit. or it could be case of request being rejected by azure as it may have resembled a DDOS attack. – Aravind Dec 26 '19 at 16:39
  • @PurnimaNaik Is your production environment is a load-balanced environment? – Rafaqat Ali Dec 26 '19 at 18:53

0 Answers0