c# - 使用 Microsoft.AspNetCore.NodeServices 调用 JS 文件时获取 Node 调用超时错误

标签 c# node.js asp.net-core

标题 使用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/

相关文章:

node.js - “Proxying” 使用 Node.js + Express 2 的大量 HTTP 请求

javascript - 如何使用 Jquery 发布对象数组?

node.js - 无法在 debian 上安装 node-libcurl

asp.net-core - SignalR 核心和跨域请求问题

c# - 在 ASP.Net Core 3.1 API 中记录响应正文

c# - 是否可以超时调用 HttpListener.GetContext?

c# - JSON.NET 序列化在 ApiController 中的行为不同

c# - 如何将 DropDownList 与列表的选择结果绑定(bind)

c# - 使用 mvvm 填充 Listview

asp.net-core - 使用应用程序网关的 Azure AD 重定向 URL