Search code examples
phpphpexceldompdf

PHPExcel - DOMPdf Connection Reset


I'm using PHPExcel library to generate a report for my website. I'm using it with DOMPdf to export the reports to PDF. This works fine for small reports, but when I have a lot of data to export it shows "net::ERR_CONNECTION_RESET". Do you have any idea why this is happening? Any help will be very appreciated.

This is the code that I'm using to generate pdf:

public function export_pdf($objPHPExcel,$nameFile){

    $rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
    $rendererLibrary = 'dompdf';
    $rendererLibraryPath = dirname(dirname(__FILE__)) . '/Vendor/' . $rendererLibrary;
    PHPExcel_Settings::setPdfRenderer($rendererName,$rendererLibraryPath);

    $chartRendererName =   PHPExcel_Settings::CHART_RENDERER_LIBCHART;
    $chartRendererLibrary = dirname(dirname(__FILE__)) . '/Vendor/libchart/classes';
    PHPExcel_Settings::setChartRenderer($chartRendererName, $chartRendererLibrary);

    $worksheet = $objPHPExcel->getActiveSheetIndex();
    $objPHPExcel->getActiveSheet()->setShowGridlines(false);
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'PDF');
    $objWriter->setIncludeCharts(TRUE);
    $objWriter->setSheetIndex($worksheet);
    $date = new DateTime();
    $objWriter->save('outputfiles/'.$nameFile.$date->getTimestamp().'.pdf');
    $url = Router::url('/outputfiles/', true).$nameFile.$date->getTimestamp().'.pdf';
    return $url;
}

This is what I'm getting in php_error.log:

[16-May-2016 15:42:30 America/New_York] PHP   6. ReportsController->getTodosforReport() C:\xampp\htdocs\reinier\lib\Cake\Controller\Controller.php:490

[16-May-2016 15:42:30 America/New_York] PHP   7. ReportsController->reservesWithTraces() C:\xampp\htdocs\reinier\app\Controller\ReportsController.php:966

[16-May-2016 15:42:30 America/New_York] PHP   8. ReportsController->export_pdf() C:\xampp\htdocs\reinier\app\Controller\ReportsController.php:1099

[16-May-2016 15:42:30 America/New_York] PHP   9. PHPExcel_Writer_PDF->save() C:\xampp\htdocs\reinier\app\Controller\ReportsController.php:947

[16-May-2016 15:42:30 America/New_York] PHP  10. PHPExcel_Writer_PDF_DomPDF->save() C:\xampp\htdocs\reinier\app\Vendor\PHPExcel\Writer\PDF.php:87

[16-May-2016 15:42:30 America/New_York] PHP  11. spl_autoload_call() C:\xampp\htdocs\reinier\app\Vendor\PHPExcel\Writer\PDF.php:94

[16-May-2016 15:42:30 America/New_York] PHP  12. DOMPDF_autoload() C:\xampp\htdocs\reinier\app\Vendor\PHPExcel\Writer\PDF.php:0

UPDATE: I added this two lines to the function below and nothing changes

 ini_set("memory_limit", '1024M');
 ini_set('max_execution_time', 0);

Any other suggestion?

UPDATE:

This is what I get in apache error.log file

[Tue May 17 17:23:33.737245 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00428: Parent: child process 15620 exited with status 3221225725 -- Restarting.
[Tue May 17 17:23:34.453984 2016] [ssl:warn] [pid 14132:tid 580] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:23:34.545773 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00455: Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 configured -- resuming normal operations
[Tue May 17 17:23:34.545773 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00456: Apache Lounge VC11 Server built: Nov 21 2013 20:13:01
[Tue May 17 17:23:34.545773 2016] [core:notice] [pid 14132:tid 580] AH00094: Command line: 'c:\\xampp_183\\apache\\bin\\httpd.exe -d C:/xampp_183/apache'
[Tue May 17 17:23:34.548702 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00418: Parent: Created child process 9356
[Tue May 17 17:23:35.122875 2016] [ssl:warn] [pid 9356:tid 536] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:23:35.373832 2016] [ssl:warn] [pid 9356:tid 536] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:23:35.417773 2016] [mpm_winnt:notice] [pid 9356:tid 536] AH00354: Child: Starting 150 worker threads.
[Tue May 17 17:25:11.545808 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00428: Parent: child process 9356 exited with status 3221225725 -- Restarting.
[Tue May 17 17:25:12.264499 2016] [ssl:warn] [pid 14132:tid 580] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:25:12.307465 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00455: Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 configured -- resuming normal operations
[Tue May 17 17:25:12.308442 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00456: Apache Lounge VC11 Server built: Nov 21 2013 20:13:01
[Tue May 17 17:25:12.308442 2016] [core:notice] [pid 14132:tid 580] AH00094: Command line: 'c:\\xampp_183\\apache\\bin\\httpd.exe -d C:/xampp_183/apache'
[Tue May 17 17:25:12.310395 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00418: Parent: Created child process 11884
[Tue May 17 17:25:12.858201 2016] [ssl:warn] [pid 11884:tid 564] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:25:13.098416 2016] [ssl:warn] [pid 11884:tid 564] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:25:13.143335 2016] [mpm_winnt:notice] [pid 11884:tid 564] AH00354: Child: Starting 150 worker threads.

Solution

  • From the comment back-and-forth:

    A connection reset rather than a 500 has, in my experience, been the result of a crash of the web server (typically apache). If this is the case you won't see any indication in the PHP log but you would see a notice in the apache log.

    The error you are seeing

    Parent: child process 15620 exited with status 3221225725 -- Restarting.

    does look to be an apache thread crash. The crash indicated by this log entry is indeterminte, you would need a crash dump to analyze. But based on the comments I'd agree with Mark that it's probably a memory over-run, but in apache instead of PHP.

    Maybe increase the apache thread stack size (via my above google search)?