What aspect of Azure App Service determines the elapsed time limit?

时间秒杀一切 提交于 2021-02-11 00:22:27

问题


What in Azure App Service determines the elapsed time limit? The controller method...

[Route("service")]
[HttpPost]
public Outbound Post(Inbound inbound)
{
    Debug.Assert(inbound.Message.Equals("Hello server."));
    Outbound outbound = new Outbound();
    long Billion = 1000000000;
    for (long i = 0; i < 30 * Billion; i++) // 215 seconds
        ;
    outbound.Message = String.Format("The server processed inbound object.");
    return outbound;
}

The client side...

    static void Main(string[] args)
    {
        Post().GetAwaiter().GetResult();
    }
    static async Task<Outbound> Post() 
    {
        Outbound outbound = null;
        Inbound inbound = new Inbound();
        inbound.Message = "Hello server.";
        Task<Outbound> task = PostInbound(inbound);
        outbound = await task;
        // the assert sometimes fails because outbound is null
        Debug.Assert(outbound.Message.Equals("The server processed inbound object."));
        return outbound;
    }   
    static async Task<Outbound> PostInbound(Inbound inbound)
    {
        Outbound outbound = null;
        HttpClient client = new HttpClient();
        client.Timeout = TimeSpan.FromSeconds(1000.0d);
        client.BaseAddress = new Uri("https://z.azurewebsites.net/", UriKind.Absolute);
        Task<HttpResponseMessage> task0 = 
            client.PostAsJsonAsync<Inbound>(
                 new Uri("controller/service", UriKind.Relative),
                 inbound);
        HttpResponseMessage response = await task0;
        if (response.IsSuccessStatusCode)
        {
            HttpContent content = response.Content;
            Task<Outbound> task1 = content.ReadAsAsync<Outbound>();
            outbound = await task1;
        }
        return outbound;
    }

The failure is that the deserialized object reference is sometimes null. In other words the Outbound object reference is null. Failure is very likely beyond the number of iterations shown.

来源:https://stackoverflow.com/questions/63145037/what-aspect-of-azure-app-service-determines-the-elapsed-time-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!