NetTalk Central

Author Topic: Preventing Browser timeouts when generating large files or reports.  (Read 13447 times)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11181
    • View Profile
This information applies to version 4.32 and later.

Preamble

If you generate a file "on demand", such as a Report (PDF), Graphic image, Excel file, or whatever, and it takes a "long time" to generate, then the browser can time out. A mechanism is needed to tell the browser to "wait a bit longer".

HTML pages

The solution for HTML pages is easy - just send a space character at regular intervals using the ParseHTML method.

Binary Pages

the solution for binary files is more complex as characters cannot be added to the "front" of the file. Typically the whole file has to be generated before any of it can be sent, and equally, whatever is sent must not end up being part of the file being sent.

Solution

The solution is the .NoOp method. This method should be called _before_ sending the resultant file & header. In other words it can be called 1 or more time _before_ sending a binary file (with header in the normal way) back to the browser.

It can be called multiple times. Internally it will only send a packet every 15 seconds, so you do not need to do any time calculations yourself.

Support for this method has been added to the ABC Report template, the call to .NoOp is added to the TakeRecord method. In Legacy reports it is added to the start of the GetNextRecord routine.

If you are hand-coding a report, or using another report template (CPCS etc) then feel free to add the call;
if not p_web &= Null then p_web.NoOp().
as the report loops through the file.

Really really big files

If your files are really large, or take a really long time to generate, then you may want to re-think the strategy somewhat. It is almost certainly better to let the user request the file online, but then deliver the file to them via email. This is safer (reduces the chance of the user closing the browser window by mistake) and allows the user to have a record of the file (and not have to re-generate it all the time.)

Cheers
Bruce