简体   繁体   中英

Azure App Service outbound request timeout

My .NET site is hosted on Azure App Service.

I have a background task that calls an external API which returns a json (~5MB) and that takes typically 3-4 minutes to complete when I test it in my browser.

But this call fails when executed from the Azure server.

var request = (HttpWebRequest)WebRequest.Create(apiUrl);
request.Timeout = request.ReadWriteTimeout = 15 * 60 * 1000; // 15 mins
request.Accept = "application/json";

var response = request.GetResponse();
using (var reader = new StreamReader(response.GetResponseStream()))
{
    var result = reader.ReadToEnd();
    ...
}

I've tried calling other API endpoints which are faster on the same domain and they work fine, so it is not a matter of Azure servers being blocked or anything.

I have the feeling that Azure kills the connection at some point.

My logs are showing the following:

18/02/2019 12:00:00 PM Downloading the packages data from https://xxxx/api/grouptours/

18/02/2019 12:15:00 PM System.Net.WebException: The operation has timed out

EDIT : although the site is running on multiple instances, we do not have a Load Balancer nor Traffic Manager setup.

Azure Load Balancer has a default idle timeout setting of little less than four minutes (230 Sec) according to documentation : Why does my request time out after 230 seconds?

For a background task you could look at webjob or azure function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM