1

I have a TimerTrigger which calls my own Azure Functions at a relatively high rate - a few times per second. It is not being stress tested. Every call takes just a 100ms and the purpose of the test is not a stress test.

This call to my own endpoint works about 9999 times out of 10000 but just once in a while I get the following error:

System.Net.Http.HttpRequestException: Name or service not known (app.mycustomdomain.com:443)
 ---> System.Net.Sockets.SocketException (0xFFFDFFFF): Name or service not known
   at System.Net.Sockets.Socket.AwaitableSocketAsyncEventArgs.ThrowException(SocketError error, CancellationToken cancellationToken)

I replaced my actual domain with "app.mycustomdomain.com" in the error message above. It is a custom domain set up to point to the Azure Function App using CNAME.

The Function App does not detect any downtime in the Azure Portal and I have Application Insights enabled and do not see any errors. So I assume the issue is somehow on the callers side and the call never actually happens.

What does this error indicate? And how can I alleviate the problem?

Niels Brinch
  • 3,033
  • 9
  • 48
  • 75

1 Answers1

1

For your second question - alleviating the problem, one option would certainly be to build in retry using a library like Polly. High level you create a policy, e.g. for a simple retry:

var myPolicy = Policy
  .Handle<SomeExceptionType>()
  .Retry(3);

This would retry 3 times, to use the policy you can call a sync or async version of Execute:

await myPolicy.ExecuteAsync(async () =>
{
     //do stuff that might fail up to three times
});

More complete samples are available

This library has lots of support for other approaches, e.g. with delays, exponential delays, etc.

Matt
  • 12,569
  • 4
  • 44
  • 42
  • Thank you and then I guess the implied answer to the first question is to expect that this sort of random thing happens from time to time. I am just burdened by the knowledge that there is a reason for everything. – Niels Brinch Jul 17 '21 at 06:43
  • 1
    It’s always safe to assume these random things happen, that’s not to say someone else couldn’t give you the reason for the original issue. I hope Polly can alleviate some of your burden! :) – Matt Jul 17 '21 at 20:49
  • 1
    Thank you. Got it implemented with some difficulty and it seems to have alleviated it somewhat. – Niels Brinch Jul 18 '21 at 15:45
  • Actually it doesn't work for me, but that's a new question. I am probably doing it wrong: https://stackoverflow.com/questions/68557887/polly-does-not-timeout – Niels Brinch Jul 28 '21 at 10:06