06-27-2017 03:52 PM - edited 03-01-2019 03:53 AM
A common question from developers building actions.
When executing an action, the following error is seen:
admin@ncs> request services service example my-long-running-action
Error: application timeout
[error][2017-03-10 11:22:16]
admin@ncs>
And in the log (for Java):
<ERROR> 10-Mar-2017::11:22:16.871 Dp NCS-DpMUX-18-example:APprovider: -
com.tailf.conf.ConfException: unexpected end of file
at com.tailf.conf.ConfInternal.readFill(ConfInternal.java:415)
at com.tailf.conf.ConfInternal.termRead(ConfInternal.java:185)
at com.tailf.conf.ConfInternal.termRead(ConfInternal.java:113)
at com.tailf.dp.Dp.read(Dp.java:1728)
at com.tailf.ncs.ctrl.NcsDpMux.run(NcsDpMux.java:175)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException
... 6 more
<WARN> 10-Mar-2017::11:22:16.871 NcsDpMux NCS-DpMUX-18-example:APprovider: - Error in NcsDpMux
com.tailf.conf.ConfException: unexpected end of file
at com.tailf.conf.ConfInternal.readFill(ConfInternal.java:415)
at com.tailf.conf.ConfInternal.termRead(ConfInternal.java:185)
at com.tailf.conf.ConfInternal.termRead(ConfInternal.java:113)
at com.tailf.dp.Dp.read(Dp.java:1728)
at com.tailf.ncs.ctrl.NcsDpMux.run(NcsDpMux.java:175)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.EOFException
... 6 more
<ERROR> 10-Mar-2017::11:22:16.872 NcsMain NCS-DpMUX-18-example:APprovider: - Received exception from package 'example' Message: 'unexpected end of file'
Where do you increase the timeout?
Solved! Go to Solution.
06-27-2017 03:54 PM
Action time outs are managed inside the action code (unlike service timeouts).
Here's an example to extend the action timeout. You can call this multiple times to extend the timeout (e.g. if you loop through some long running actions, in a simplistic scenario it might make sense to increase the timeout for each action).
private static final int TIMEOUT_IN_SEC = 420; // 7 * 60
public ConfXMLParam[] longRunningAction (DpActionTrans trans, ConfTag name,
ConfObject[] reverseKeyPath,
ConfXMLParam[] params)
throws DpCallbackException {
try {
trans.actionSetTimeout( TIMEOUT_IN_SEC );
}
catch ( IOException ioe ) {
throw new DpCallbackException( "IOException in setting Action timeout", ioe );
}
//Rest of code
}
Similarly in Python:
class LongRunningAction(Action):
@Action.action
def cb_action(self, userInfo, name, kp, input, output):
_ncs.dp.action_set_timeout(userInfo,240)
#Rest of code
06-27-2017 03:54 PM
Action time outs are managed inside the action code (unlike service timeouts).
Here's an example to extend the action timeout. You can call this multiple times to extend the timeout (e.g. if you loop through some long running actions, in a simplistic scenario it might make sense to increase the timeout for each action).
private static final int TIMEOUT_IN_SEC = 420; // 7 * 60
public ConfXMLParam[] longRunningAction (DpActionTrans trans, ConfTag name,
ConfObject[] reverseKeyPath,
ConfXMLParam[] params)
throws DpCallbackException {
try {
trans.actionSetTimeout( TIMEOUT_IN_SEC );
}
catch ( IOException ioe ) {
throw new DpCallbackException( "IOException in setting Action timeout", ioe );
}
//Rest of code
}
Similarly in Python:
class LongRunningAction(Action):
@Action.action
def cb_action(self, userInfo, name, kp, input, output):
_ncs.dp.action_set_timeout(userInfo,240)
#Rest of code
06-27-2017 06:03 PM
Good for our Knowledge Base!
In addition to that, users can find working example from here. FYI.
$NCS_DIR/examples.ncs/getting-started/developing-with-ncs/2-actions/packages/actions/src/java/src/com/example/actions/ActionCb.java
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide