HTTP Trigger Azure Function APP Times out on Azure only after 23 seconds

Viewed 945

I have got a Azure Function APP, HTTP trigger calling a webservice and passing on Soap message containing XML. (hosted via APP service plan) Locally, using VS2019 the function successfully reaches the web service and receives response within 25 seconds or less. When published to Azure, the function timesout only after < 23 Seconds.

I get a HTTP server 500 error back: 2021-10-20T09:54:46.263 [Error] Executed 'XXXX' (Failed, Id=0cc4db22-f9ba-4c5d-9f6e-ecd1da394333, Duration=22131ms)A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Update: this has been resolved by creating a virtual network for all outbound requests for the function app https://docs.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-nat-gateway.

2 Answers

You can try to reach to the SOAP webservice that your are trying to hit from the kudu console of your function app. see details at https://github.com/Azure/azure-functions-host/issues/957 , most likely the outbound IP address of azure is not whitelisted by your server hosting the SOAP webservice.

Thank you Jerry Liu posting your suggestion as an answer to help other community members.

"It is expected. Http request has a fixed timeout setting on Azure site. See Azure Web App timeout setting of 230s. In this aspect, there's no difference between Azure Web app and Http trigger Azure Function.

There is a 230 second (i.e. a little less than 4 mins) timeout for requests that are not sending any data back. After that, the client gets the 500 you saw, even though in reality the request is allowed to continue server side.

As for how to bypass this limitation, if it's not necessary to get an immediate feedback like httpresponse, you can use queue trigger to do your job.

Otherwise, have a look at Durable function. You could send an http request to start an orchestrator and get a response that it starts successfully and so on. The work is being processed in orchestrator and activity function and we don't need to worry about time out(as they are non-http trigger as well)."

Related