Description
Describe the bug
When attempting to print to PDF from a host or service page using the pdfexport module, I receive this error
Received empty response or none at all from browser. Please check the logs for further details. #0 /usr/share/icinga-php/ipl/vendor/evenement/evenement/src/EventEmitterTrait.php(143): Icinga\Module\Pdfexport\HeadlessChrome->Icinga\Module\Pdfexport\{closure}() Icinga/icingaweb2#1 /usr/share/icinga-php/vendor/vendor/react/stream/src/ReadableResourceStream.php(148): Evenement\EventEmitter->emit() Icinga/icingaweb2#2 /usr/share/icinga-php/ipl/vendor/react/event-loop/src/StreamSelectLoop.php(246): React\Stream\ReadableResourceStream->handleData() Icinga/icingaweb2#3 /usr/share/icinga-php/ipl/vendor/react/event-loop/src/StreamSelectLoop.php(213): React\EventLoop\StreamSelectLoop->waitForStreamActivity() Icinga/icingaweb2#4 /usr/share/icinga-php/ipl/vendor/react/event-loop/src/Loop.php(250): React\EventLoop\StreamSelectLoop->run() Icinga/icingaweb2#5 /usr/share/icingaweb2/modules/pdfexport/library/Pdfexport/HeadlessChrome.php(407): React\EventLoop\Loop::run() Icinga/icingaweb2#6 /usr/share/icingaweb2/modules/pdfexport/library/Pdfexport/ProvidedHook/Pdfexport.php(77): Icinga\Module\Pdfexport\HeadlessChrome->toPdf() Icinga/icingaweb2#7 /usr/share/icingaweb2/modules/pdfexport/library/Pdfexport/ProvidedHook/Pdfexport.php(136): Icinga\Module\Pdfexport\ProvidedHook\Pdfexport->htmlToPdf() Icinga/icingaweb2#8 /usr/share/php/Icinga/Common/PdfExport.php(73): Icinga\Module\Pdfexport\ProvidedHook\Pdfexport->streamPdfFromHtml() Icinga/icingaweb2#9 /usr/share/php/Icinga/Web/Controller/ActionController.php(568): Icinga\Web\Controller\ActionController->newSendAsPdf() Icinga/icingaweb2#10 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Web/Controller.php(422): Icinga\Web\Controller\ActionController->sendAsPdf() Icinga/icingaweb2#11 /usr/share/php/Icinga/Web/Controller/ActionController.php(516): Icinga\Module\Icingadb\Web\Controller->sendAsPdf() Icinga/icingaweb2#12 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Compat/CompatController.php(510): Icinga\Web\Controller\ActionController->postDispatch() Icinga/icingaweb2#13 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Web/Controller.php(540): ipl\Web\Compat\CompatController->postDispatch() Icinga/icingaweb2#14 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Web/Controller.php(478): Icinga\Module\Icingadb\Web\Controller->postDispatch() Icinga/icingaweb2#15 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Icinga\Module\Icingadb\Web\Controller->dispatch() Icinga/icingaweb2#16 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Front.php(954): Icinga\Web\Controller\Dispatcher->dispatch() Icinga/icingaweb2#17 /usr/share/php/Icinga/Application/Web.php(294): Zend_Controller_Front->dispatch() Icinga/icingaweb2#18 /usr/share/php/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch() Icinga/icingaweb2#19 /usr/share/icingaweb2/public/index.php(4): require_once(String) Icinga/icingaweb2#20 {main}
After enabling DEBUG in icingaweb2 I get this
Feb 10 22:21:38 icinga000000 icingaweb2[44698]: Failed to print PDF. An error occurred: ErrorException in /usr/share/php/Icinga/Date/DateFormatter.php:109 with message: Object of class DateTime could not be converted to int Feb 10 22:21:39 icinga000000 icingaweb2[44698]: Exception in /usr/share/icingaweb2/modules/pdfexport/library/Pdfexport/HeadlessChrome.php:355 with message: Received empty response or none at all from browser. Please check the logs for further details. #0 /usr/share/icinga-php/ipl/vendor/evenement/evenement/src/EventEmitterTrait.php(143): Icinga\Module\Pdfexport\HeadlessChrome->Icinga\Module\Pdfexport\{closure}() Icinga/icingaweb2#1 /usr/share/icinga-php/vendor/vendor/react/stream/src/ReadableResourceStream.php(148): Evenement\EventEmitter->emit() Icinga/icingaweb2#2 /usr/share/icinga-php/ipl/vendor/react/event-loop/src/StreamSelectLoop.php(246): React\Stream\ReadableResourceStream->handleData() Icinga/icingaweb2#3 /usr/share/icinga-php/ipl/vendor/react/event-loop/src/StreamSelectLoop.php(213): React\EventLoop\StreamSelectLoop->waitForStreamActivity() Icinga/icingaweb2#4 /usr/share/icinga-php/ipl/vendor/react/event-loop/src/Loop.php(250): React\EventLoop\StreamSelectLoop->run() Icinga/icingaweb2#5 /usr/share/icingaweb2/modules/pdfexport/library/Pdfexport/HeadlessChrome.php(407): React\EventLoop\Loop::run() Icinga/icingaweb2#6 /usr/share/icingaweb2/modules/pdfexport/library/Pdfexport/ProvidedHook/Pdfexport.php(77): Icinga\Module\Pdfexport\HeadlessChrome->toPdf() Icinga/icingaweb2#7 /usr/share/icingaweb2/modules/pdfexport/library/Pdfexport/ProvidedHook/Pdfexport.php(136): Icinga\Module\Pdfexport\ProvidedHook\Pdfexport->htmlToPdf() Icinga/icingaweb2#8 /usr/share/php/Icinga/Common/PdfExport.php(73): Icinga\Module\Pdfexport\ProvidedHook\Pdfexport->streamPdfFromHtml() Icinga/icingaweb2#9 /usr/share/php/Icinga/Web/Controller/ActionController.php(568): Icinga\Web\Controller\ActionController->newSendAsPdf() Icinga/icingaweb2#10 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Web/Controller.php(422): Icinga\Web\Controller\ActionController->sendAsPdf() Icinga/icingaweb2#11 /usr/share/php/Icinga/Web/Controller/ActionController.php(516): Icinga\Module\Icingadb\Web\Controller->sendAsPdf() Icinga/icingaweb2#12 /usr/share/icinga-php/ipl/vendor/ipl/web/src/Compat/CompatController.php(510): Icinga\Web\Controller\ActionController->postDispatch() Icinga/icingaweb2#13 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Web/Controller.php(540): ipl\Web\Compat\CompatController->postDispatch() Icinga/icingaweb2#14 /usr/share/icingaweb2/modules/icingadb/library/Icingadb/Web/Controller.php(478): Icinga\Module\Icingadb\Web\Controller->postDispatch() Icinga/icingaweb2#15 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(76): Icinga\Module\Icingadb\Web\Controller->dispatch() Icinga/icingaweb2#16 /usr/share/icinga-php/vendor/vendor/shardj/zf1-future/library/Zend/Controller/Front.php(954): Icinga\Web\Controller\Dispatcher->dispatch() Icinga/icingaweb2#17 /usr/share/php/Icinga/Application/Web.php(294): Zend_Controller_Front->dispatch() Icinga/icingaweb2#18 /usr/share/php/Icinga/Application/webrouter.php(105): Icinga\Application\Web->dispatch() Icinga/icingaweb2#19 /usr/share/icingaweb2/public/index.php(4): require_once(String) Icinga/icingaweb2#20 {main}
Expected behavior
PDF page for review or print. NOTE - PDF export works fine for both History and Documentation
Your Environment
Include as many relevant details about the environment you experienced the problem in
-
Icinga Web 2 version and modules (System - About): 2.12.2
-
Web browser used: Brave - Version 1.73.101 Chromium: 131.0.6778.139 (Official Build) (arm64)
-
Icinga 2 version used (
icinga2 --version
):
icinga2 - The Icinga 2 network monitoring daemon (version: r2.14.5-1) System information: Platform: Ubuntu Platform version: 22.04.5 LTS (Jammy Jellyfish) Kernel: Linux Kernel version: 6.8.0-1020-azure Architecture: x86_64 Build information: Compiler: GNU 11.4.0 Build host: runner-hh8q3bz2-project-575-concurrent-0 OpenSSL version: OpenSSL 3.0.2 15 Mar 2022
-
PHP version used (
php --version
):
PHP 8.1.2-1ubuntu2.20 (cli) (built: Dec 3 2024 20:14:35) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.2, Copyright (c) Zend Technologies with Zend OPcache v8.1.2-1ubuntu2.20, Copyright (c), by Zend Technologies
-
Server operating system and version: Linux icinga000004 6.8.0-1020-azure Italian UI Language: updated icingaweb2#23~22.04.1-Ubuntu SMP Mon Dec 9 17:50:51 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Additional context
with some AI help, this patch fixes my problem, but I'm not going to author a PR with AI code
109c109,118
< return date('Y-m-d H:i:s', (int) $dateTime);
---
> if (is_object($dateTime) && method_exists($dateTime, 'getTimestamp')) {
> $time = $dateTime->getTimestamp();
> } else {
> $time = (int)$dateTime;
> }
> try {
> return date('Y-m-d H:i:s', $time);
> } catch (\Exception $e) {
> throw new \RuntimeException("Failed to format datetime: " . $e->getMessage());
> }
Activity