标题 使用Microsoft.AspNetCore.NodeServices调用JS文件时获取Node调用超时错误
功能影响 我开发了使用 NodeServices 的应用程序,并使用以下文章将其部署在 Azure 上: https://code.msdn.microsoft.com/How-to-export-HTML-to-PDF-c5afd0ce
它在本地工作,但在部署版本上不工作。 获取 Node 超时错误:
The Node invocation timed out after 60000ms.
You can change the timeout duration by setting the InvocationTimeoutMilliseconds property on NodeServicesOptions.
The first debugging step is to ensure that your Node.js function always invokes the supplied callback (or throws an exception synchronously), even if it encounters an error. Otherwise, the .NET code has no way to know that it is finished or has failed. | Source: Microsoft.AspNetCore.NodeServices
预期结果 应创建 PDF。
实际结果 NodeService抛出超时错误
但在部署的版本上仍然出现超时错误。任何帮助,将不胜感激。谢谢。
最佳答案
您可以在将 NodeServices 添加到服务容器时指定超时 - 您还可以在那里设置一个 ILogger,这可能有助于您调试问题:
services.AddNodeServices(options =>
{
options.InvocationTimeoutMilliseconds = TimeSpan.FromMinutes(5).Milliseconds;
options.NodeInstanceOutputLogger = log;
});
关于c# - 使用 Microsoft.AspNetCore.NodeServices 调用 JS 文件时获取 Node 调用超时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50376225/