问题
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