Blocking action invocation time-outs after 60s - how to access result?

风格不统一 提交于 2020-01-05 02:32:56

问题


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})

...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.

How can I retrieve an action result for an invocation which takes longer than a minute?


回答1:


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:

  • 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.

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.



来源:https://stackoverflow.com/questions/56144599/blocking-action-invocation-time-outs-after-60s-how-to-access-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!