PHPExcel - DOMPdf 连接重置
PHPExcel - DOMPdf Connection Reset
我正在使用 PHPExcel 库为我的网站生成报告。我将它与 DOMPdf 一起使用以将报告导出为 PDF。这适用于小型报告,但当我有大量数据要导出时,它会显示 "net::ERR_CONNECTION_RESET"。
你知道为什么会这样吗?
任何帮助将不胜感激。
这是我用来生成 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;
}
这就是我在 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
更新:
我将这两行添加到下面的函数中,没有任何变化
ini_set("memory_limit", '1024M');
ini_set('max_execution_time', 0);
还有其他建议吗?
更新:
这是我在 apache error.log 文件中得到的
[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.
来自来回评论:
根据我的经验,连接重置而不是 500 是 Web 服务器(通常是 Apache)崩溃的结果。如果是这种情况,您将不会在 PHP 日志中看到任何指示,但您会在 apache 日志中看到一条通知。
您看到的错误
Parent: child process 15620 exited with status 3221225725 -- Restarting.
看起来确实是 apache 线程崩溃。此日志条目指示的崩溃是 indeterminte,您需要一个故障转储来分析。但根据评论,我同意 Mark 的观点,即它可能是内存超过 运行,但在 apache 中而不是 PHP。
也许 increase the apache thread stack size(通过我上面的 google 搜索)?
我正在使用 PHPExcel 库为我的网站生成报告。我将它与 DOMPdf 一起使用以将报告导出为 PDF。这适用于小型报告,但当我有大量数据要导出时,它会显示 "net::ERR_CONNECTION_RESET"。 你知道为什么会这样吗? 任何帮助将不胜感激。
这是我用来生成 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;
}
这就是我在 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
更新: 我将这两行添加到下面的函数中,没有任何变化
ini_set("memory_limit", '1024M');
ini_set('max_execution_time', 0);
还有其他建议吗?
更新:
这是我在 apache error.log 文件中得到的
[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.
来自来回评论:
根据我的经验,连接重置而不是 500 是 Web 服务器(通常是 Apache)崩溃的结果。如果是这种情况,您将不会在 PHP 日志中看到任何指示,但您会在 apache 日志中看到一条通知。
您看到的错误
Parent: child process 15620 exited with status 3221225725 -- Restarting.
看起来确实是 apache 线程崩溃。此日志条目指示的崩溃是 indeterminte,您需要一个故障转储来分析。但根据评论,我同意 Mark 的观点,即它可能是内存超过 运行,但在 apache 中而不是 PHP。
也许 increase the apache thread stack size(通过我上面的 google 搜索)?