KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Timeout error for the cloud export #1636

Open Mike opened this topic on on Sep 30, 2020 - 9 comments

Mike commented on Sep 30, 2020

Am getting an execution timeout error while generating PDF report using the cloud export package. Also, increased the max_execution_time() in the php.ini file but, still facing the same issue.

David Winterburn commented on Sep 30, 2020

Hi Mike,

How long did you set max_execution_time for your server's php.ini? If you only used a simple report's view, like a simple hello world html file, would cloud export work?

Mike commented on Oct 1, 2020

I have set max_execution_time = 300 in the php.ini file.

AS you mentioned in the previous comment, I have tried the simple report view and now getting uncaught Exception like Could not save content to a temporary folder. Actually, I want to display the PDF file on the browser so used below code

$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio($secretToken)
->pdf()
->toBrowser("myreport.pdf");

Can you help to resolve the issue?

Mike commented on Oct 1, 2020

It seems that the cloud export is using user local tmp folder by default. Is there any way to change this path?

David Winterburn commented on Oct 1, 2020

Hi Mike,

By default, cloud export use system temp folder to save temporary files. If you had trouble saving temporary files (often it's a permission issue) please try to use a local temporary folder with this option:

$report->run()
->cloudExport("MyReportPDF")
->chromeHeadlessio($secretToken)
->settings([
    "useLocalTempFolder" => true,
])
->pdf()
->toBrowser("myreport.pdf");

Let us know how it works for you. Thanks!

Mike commented on Oct 3, 2020

Hi David,

Still getting the same error that "Could not save content to temporary folder". Please advise.

David Winterburn commented on Oct 5, 2020

Hi Mike,

Please check to see if there's a "tmp" folder in your report folder. If there's one, please try to run a php file with this simple command to see if it returns any error:

<?php
    ini_set('display_errors', '1');
    ini_set('display_startup_errors', '1');
    error_reporting(E_ALL);
    file_put_contents($pathToTmp . "/test.txt", "Hello world");
Mike commented on Oct 5, 2020

Hi David,

I have tried the above mentioned php code and its working fine. It's created the test.txt file in the tmp folder.

Actually the tmp folder is not a issue. The processing file export.html is generated in the tmp folder but there is no content in it. Also, I have checked the chromeheadlessio/php-client/src/Exporter.php file for the tmp folder path and file content. The tmp folder path is like F:\xampp\htdocs\pos\tmp. But when I uncommented below lines in the Exporter.php file to get the content , its empty.

echo ($content); 
echo htmlentities($content); 
exit();

Can you check these details and advise?

Mike commented on Oct 5, 2020

It's my mistake that earlier html content is not coming. Now am able to get the content.

But now the cloud export is taking long time for execution and getting error "Maximum execution time of 300 seconds exceeded". As mentioned by you earlier, am using the small file content like

<html>
    <body>
        <h1>This is my first export using Chromeheadless.io</h1>
        <p>Chromeheadless.io save your time and resources in exporting html, report to PDF.</p>
    </body>
</html>

Also, I have checked the tmp folder and found that there are like 1000 javascript files generated. When I checked one of these js file, its showing content of our website login page. As we are generating all these reports based on user access like admin and normal user, so need to maintain user session. Is there any way to send the user authentication details in the curl call in Exporter.php script?

Can you suggest any solution for it?

David Winterburn commented on Oct 5, 2020

Hi Mike,

I think that your site first requires some login page, then uses some token in request header for authorization. To solve this problem I would suggest you you create a php file with some functions like this:

<?php
//curlFiles.php
if (! isset($_SESSION["loginToken"])) {
    $loginToken = login($userName, $password); //replace $userName and $password with yours
    $_SESSION["loginToken"] = $loginToken;
}

function login($userName, $password) {
    //use curl with $userName, $password to get response's token
    ...
    return $loginToken;
}

function curlFile($url) {
    $loginToken = $_SESSION["loginToken"];
    //use curl with $loginToken in header to get the url
    ...
    return $urlContent;
}

Then in your export.php page, include this curlFiles.php and open Exporter.php and replace this line:

    $fileContent = file_get_contents($url);

with:

    $fileContent = curlFile($url);

I don't know enough about your site's login working for a more detail outline but curl could imitate most complicated requests so if your browser can retrieve the js/css files curl can, too. Let us know if you meet any difficulty. Thanks!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

CloudExport