I have a web app calling a .Net Core API for generating PDF documents. I'm doing a bunch of HTML to pdf conversion so it takes a while to complete 200 pages document. I have it working in my local but not my AppService. At first, I was getting "The specified CGI application encountered an error and the server terminated the process." if I went over 100 pages (small page sets work).
The code calling my api:
var httpClient = new HttpClient();
HttpContent content = new StringContent(JsonConvert.SerializeObject(pdfRecipeDto), Encoding.UTF8, "application/json");
httpClient.Timeout = System.TimeSpan.FromMinutes(30);
var pdfFileUrl = httpClient.PostAsync("http://yada-yada.azurewebsites.net/api/pdf/Generate", content)
.GetAwaiter()
.GetResult()
.Content.ReadAsStringAsync().Result; // yes i know this is gross
I found this post and others that said simular. tried the first answer but after manually modifying my web.config in Kudu (bc i don't know how to set it in my project)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore requestTimeout="00:20:00" processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
the requestTimeout="00:20:00" being the important part.
But i get a "500 - The request timed out. The web server failed to respond within the specified time.".
i also tried the adding .UseKestrel(...)
to my program.cs
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseApplicationInsights()
.UseStartup<Startup>()
.UseKestrel(o =>
{
o.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(30);
})
.Build();;
But that seemed to do nothing.