Nodejs SOAP 模块 - 超时选项

问题描述 投票:0回答:3

如何设置

soap.createClient
和/或
client.myFunction
的超时?文档中没有提及。如果不可能,有解决办法吗?

node.js soap
3个回答
14
投票

经过一个小时的尝试,我发现了它,基本上它使用了 request,而 wsdl_options 会覆盖 request 选项。您可以按照下面的示例进行操作。 :))

soap.createClient(url, {wsdl_options: {timeout: 5000}}, callback)

参考:https://github.com/vpulim/node-soap#options


2
投票

这是在node-soap文档中提到的

client.MyService.MyPort.MyFunction({name: 'value'}, function(err, result) {
    // result is a javascript object
}, {timeout: 5000})

选项设置为回调函数之后的第三个参数。
https://github.com/vpulim/node-soap#options-可选

基本上它使用

request
模块进行 http 传输。所以request模块的选项对于soap模块也是有效的


0
投票

这就是我在 HTTP 级别捕获超时的结果。这些其他答案对我不起作用(

node-soap
v1.0.0)。

  const httpClient = axios.create({
    timeout: 10000, // Set timeout to 10 seconds
  });

  const client = await createClientAsync(
    path,
    { request: httpClient }
  );

我承认,我不能 100% 确定我没有通过像这样提供自己的 http 客户端而引起其他问题,但我可以可靠地得到一个 Axios 错误,如果我模拟我的 SOAP 服务器采用 + 10秒回复。

© www.soinside.com 2019 - 2024. All rights reserved.