Question
· Jan 6, 2016

How to increase the timeout for ZEN refreshContents() ?

When refreshing a html or tablePane component using refreshContents() that takes a lot of server-side-processing, I'm running into timeouts every now and then. i.e., the result for the tablePane is that there's nothing displayed at all.

How can we configure (relax) that timeout so also those heavier ones get refreshed eventually? Just overriding %request.Timeout in %OnPreHTTP did not seem to do the trick.

Discussion (2)2
Log in or sign up to continue

Hi Benjamin,

As a fellow Cache Developer I can offer a couple of suggestions.  If you want the user to have to wait for the server side processing to complete before continuing with their work, then you could override the CSP Gateway Response Timeout:

1.  If you are working with a ZEN page (i.e. that extends from %ZEN.component.page), then you could implement an overridden version of the OnPreHyperEvent method

Example:

 /// OnPreHyperEvent - Event handler which is invoked before a hyperevent
///   method is called on all Zen pages. The purpose of this method is to
///   allow various configuration settings to be overridden prior to making
///   the actual hyperevent call (i.e. executing a query for a tablepane).
ClassMethod OnPreHyperEvent(class As %String, method As %String) As %Status [ ServerOnly = 1 ]
{
// Override the CSP Gateway Response Timeout
Set %response.Timeout={numberOfSecondsYouWantToAllowForServerProcessingToCompleteBeforeRequestTimesOut}

// Call built-in Zen Controller pre hyperevent method
Quit ##class(%ZEN.Controller).OnPreHyperEvent(..%ClassName(1),$G(method),+..#AUTONS,..#RESOURCE)
}
 

2.  If you are working with a CSP page (i.e. that extends from %CSP.Page), then you could implement an overridden version of the OnPreHTTP method

Example:

 /// Event handler for <b>PreHTTP</b> event: this is invoked before
/// the HTTP headers for a CSP page have been sent. All changes to the
/// <class>%CSP.Response</class> class, such as adding cookies, HTTP headers,
/// setting the content type etc. must be made from within the OnPreHTTP() method.
/// Also changes to the state of the CSP application such as changing
/// %session.EndSession or %session.AppTimeout must be made within the OnPreHTTP() method.
/// It is prefered that changes to %session.Preserve are also made in the OnPreHTTP() method
/// as this is more efficient, although it is supported in any section of the page.
/// Return <b>0</b> to prevent <method>OnPage</method> from being called.
ClassMethod OnPreHTTP() As %Boolean [ ServerOnly = 1 ]
{
// Override the CSP Gateway Response Timeout
Set %response.Timeout={numberOfSecondsYouWantToAllowForServerProcessingToCompleteBeforeRequestTimesOut}
Quit $$$OK
}
 

But another option to consider is to implement the ZEN page, so the user can provide the input criteria (if any) for retrieving table data and instead of having the user click a [Search] button to run the server side lookup in foreground mode (i.e. where user has to wait for the server processing to complete), you could instead implement a [Run In Background] button where you job off the server side processing, so it can run in the background, which allows the user to do other things with the application and they can check back at a later point for the status.   You could have some type of mechanism on the ZEN page that shows the user the status of the background process (i.e. Running, Completed, Error, etc...);   You can refer to the built-in  %RunBackgroundMethod method or you could implement your own application specific background type processing - example:  As the user submits various background jobs to run, you could have a tablepane display the various processes that are running with their status - then when complete, you could have a link in that table the user could click to display the associated data that was retrieved from the server.

Hope this helps and Have a Great Day!!    Happy Coding!