60秒后阻止动作调用超时-如何访问结果? [英] Blocking action invocation time-outs after 60s - how to access result?

查看:136
本文介绍了60秒后阻止动作调用超时-如何访问结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调用Apache OpenWhisk操作(使用JavaScript SDK)作为远程功能.我想等待函数结果可在我的应用程序中使用.

I'm trying to invoke an Apache OpenWhisk action (using the JavaScript SDK) as a remote function. I want to wait for the function result to be available to use in my application.

通常通过使用阻塞调用来处理,例如

This is normally handled by using a blocking invocation, e.g.

ow.actions.invoke({name, blocking: true, result: true, params})

...但是在这种情况下,该操作需要几分钟才能完成,这会导致HTTP连接超时.六十秒后,SDK会引发错误.

...but in this case, the action takes multiple minutes to complete which leads to a timeout in the HTTP connection. The SDK throws an error after sixty seconds.

如何为耗时超过一分钟的调用检索操作结果?

推荐答案

Apache OpenWhisk仅在默认时间限制为65秒的情况下才保留用于阻塞调用的打开连接.此限制由

Apache OpenWhisk will only hold open connections for a blocking invocation for a default time limit of 65 seconds. This limit is managed by the platform configuration (and not on a per-user basis).

如果您需要调用并采取行动并在等待结果时进行阻止(对于长时间运行的行动),则需要执行以下操作:

If you need to invoke and action and block on waiting for the result (for a long-running action), you need to do the following:

  • 使用非阻塞调用来调用操作.
  • 使用返回的激活标识符来轮询激活结果API.
  • 激活结果的HTTP响应将返回HTTP 404响应,直到操作完成.
  • Invoke the action using a non-blocking invocation.
  • Use the returned activation identifier to poll the activation result API.
  • The HTTP response for the activation result will return a HTTP 404 response until the action finishes.

从非阻塞调用轮询激活结果时,应对允许的最大轮询时间施加限制.这是因为其他情况(例如无效的激活标识符)可能会返回HTTP 404.强制执行时间限制可确保在应用程序代码或平台出现问题时,轮询循环最终停止!

When polling for activation results from non-blocking invocations, you should enforce a limit on the maximum polling time allowed. This is because HTTP 404s can be returned due to other scenarios (e.g. invalid activation identifiers). Enforcing a time limit ensures that, in the event of issues in the application code or the platform, the polling loop with eventually stop!

将最长轮询时间设置为操作超时限制(加上一个小的偏移量)是一个好方法.

Setting the maximum polling time to the action timeout limit (plus a small offset) is a good approach.

这篇关于60秒后阻止动作调用超时-如何访问结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆