Comments (13)
Indeed, puppeteer resp. Chromium in general uses quite a lot of RAM. Increasing memory on the server might make it a bit faster and more stable, but it shouldn't have such a great impact.
Currently the library doesn't re-use browser sessions, as it's request based, like PHP is in general. It's not optimized for generating a huge bunch of PDF files in a row. This would be a good improvement for the future.
from php-chrome-html2pdf.
Indeed, the error isn't coming from PHP. Will have to investigate this further once I have some time. Meanwhile, I released a new version of the library containing the fix mentioned earlier.
from php-chrome-html2pdf.
Hi @coxfrederic,
Generally, "TimeoutError: Navigation timeout of 30000 ms exceeded" means the page took more than 30s to load and render, which is very unlikely. If the page loads fast in a browser, it should also load fast in this library.
You need to make sure that all external URLs in the HTML are accessible from the machine where you execute the library. For example, if you have a script like <script src="http://localhost/my.js"> it could actually end up in the mentioned error, since the external resource couldn't be loaded.
If that doesn't help, you can send the HTML to my email, maybe I can spot something.
from php-chrome-html2pdf.
Hi @spiritix ,
Thanks for your quick response.
The memory on the server is limited to 2GB and I found online that Puppeteer needs around 1GB of RAM ? So we increased the memory on the server to see if that improves things.
The external URL we will replace with images instead of using fontawesome.
I see the library is creating a new instance of a browser each time and closes it. Is that the preferred way or is there also an option to re-use the same instance? Would that improve things or actually not?
from php-chrome-html2pdf.
Currently our problem seems solved by upgrading RAM, but an option for the library to re-use the same instance for X amount of time would indeed be very nice in some use cases. I'll keep an eye on it and will close this issue for now.
Anyway, awesome work on this library, and thanks for your help!
from php-chrome-html2pdf.
I'm reopening this issue since I'm getting the same error for a page that loads a lot of content. In my browser it takes around 65-70 seconds.
I have tried setting the timeout option to 300 seconds but it doesn't have any effect. I'm still getting the TimeoutError: Navigation timeout of 30000 ms exceeded after 30 seconds.
How come the timeout value is not taken into account? Any solution to this problem?
from php-chrome-html2pdf.
Can you try to open the website directly in Puppeter and convert it to PDF, to see how long it takes to load? Something like this should do it:
const puppeteer = require('puppeteer')
async function printPDF() {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://url.com', {waitUntil: 'networkidle0'});
const pdf = await page.pdf({ format: 'A4' });
await browser.close();
return pdf
})
from php-chrome-html2pdf.
It takes around 65 seconds to load
from php-chrome-html2pdf.
@coxfrederic Thanks, this confirms that it's an issue with Puppeter. Maybe this fix helps? puppeteer/puppeteer#1846 (comment)
If so, I can implement it in this library
from php-chrome-html2pdf.
Yes! That would be amazing if you could implement it
from php-chrome-html2pdf.
What I don't understand though, the timeout is still at 30seconds. So it is ignored?
I don't see how this is related to puppeteer/puppeteer#1846 (comment) that the error fires after 30 seconds even though I specified the timeout to 300 seconds.
from php-chrome-html2pdf.
Indeed, those issues are not related. I suspect that the timeout is coming from PHP and not from Puppeter, because in PHP the default timeout is also 30 seconds.
from php-chrome-html2pdf.
Based on the error I do not believe it is a PHP timeout.
TimeoutError: Navigation timeout of 30000 ms exceeded
at /var/puntoo/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer/lib/LifecycleWatcher.js:100:111
at async DOMWorld.setContent (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer/lib/DOMWorld.js:152:23)
at async Page.setContent (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer/lib/Page.js:482:9)
at async Converter._convert (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/lib/Converter.js:76:9)
at async Converter.run (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/lib/Converter.js:37:24)
at async /var/puntoo/vendor/spiritix/php-chrome-html2pdf/index.js:23:20
-- ASYNC --
at Frame. (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer/lib/helper.js:94:19)
at Page.setContent (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer/lib/Page.js:482:46)
at Page. (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/node_modules/puppeteer/lib/helper.js:95:27)
at Converter._setHtml (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/lib/Converter.js:88:21)
at Converter._convert (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/lib/Converter.js:76:20)
at Converter.run (/var/puntoo/vendor/spiritix/php-chrome-html2pdf/lib/Converter.js:37:35)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /var/puntoo/vendor/spiritix/php-chrome-html2pdf/index.js:23:20
It is thrown in
public function convert(): OutputInterface
{
$result = ProcessUtil::executeShellCommand($this->buildCommand(), $this->input->getHtml());
if (strpos(mb_strtolower($result['error']), 'error') !== false) {
throw new ConverterException('Binary error: ' . $result['error']);
}
from php-chrome-html2pdf.
Related Issues (20)
- Problem with page.waitFor HOT 1
- Headers displayed in PDF HOT 1
- Change content-disposition to attachment HOT 6
- Unable to install on Linux Server HOT 1
- Uncaught PHP Exception: Shell error: 133 HOT 4
- Shell error 127 on linux ECS aws server but works fine on local HOT 5
- Binary error HOT 1
- Failed to launch the browser process HOT 1
- Cookies are not sent to Server while fetching content of the URL HOT 1
- No images/css/assets on relative urls HOT 3
- CSS Issue unexpected identifier "font"
- Fatal error: Uncaught Spiritix\Html2Pdf\ConverterException: Binary error: # # Fatal error in , line 0
- [Upgrade] Replace eloquent/composer-npm-bridge by php-forge/foxy HOT 1
- Binary Error -> import getStdin from 'get-stdin'; ^^^^^^^^ SyntaxError: Unexpected identifier at Module._compile HOT 5
- Binary error: Puppeteer old Headless deprecation warning HOT 3
- pageNumber and totalPages are not displayed in footerTemplate HOT 3
- Feature request: Add Auto Height
- urls with "file://" get a "net::ERR_UNKNOWN_URL_SCHEME " error
- Landscape Option Not Working
- Bug: Parameter type mismatch in Converter HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-chrome-html2pdf.