In the last 4 hours, I've tried to solve a problem with the exact error message as here https://github.com/barryvdh/laravel-snappy/issues/9 and other similar issues regarding the _60 seconds timeout problem_.
First I thought that the error is caused by a bad timeout configuration at the PHP or Nginx containers or my reverse proxy (I use a https Nginx reverse proxy and the LaraDock).
After hours of testing which container may lead to the problem I've tested all timeouts and they worked correctly.
In #9 and the related issues, the "fix" was done by just optimizing the view so the script does not run longer than 60 seconds and they're fine.
In my case, I generate a PDF with around 2000 pages for a bigger print job so the generation would always take longer than the 60 seconds.
Knp\Snappy\AbstractGenerator.php provides a setTimeout() functionality that somehow told the Symphony Process to have a greater timeout.
At the moment this does not work because their is no wrapper function for setTimeout:
PDF::loadView('anschreiben', ['data' => $data])
->setPaper('a4')
->setOption('margin-top', 0)
->setOption('margin-left', 0)
->setOption('margin-right', 0)
->setOption('margin-bottom', 0)
->setTimeout(3600)
->save(storage_path('app/pdfs/') . $pdfFileName);
My problem was fixed by manually overwrite This line from false to 3600 but it would be really nice to have this in the laravel-snappy wrapper to use it as tried above.
@barryvdh just checked the config/snappy.php file again because I'm configuring a new project.
I think I've checked that the timeout is settable via the config file? :flushed:
I will check this soon...
EDIT:
Okay, I understand now.
If someone has a similar problem, you can set the timeout in the config:
'pdf' => array(
'enabled' => true,
'binary' => base_path('vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64'),
'timeout' => 3600,
'options' => array(),
'env' => array(),
),
I've just searched for the exact same issue for a while and found my old Issue with the solution! :+1: for me!
Why is the 'timeout' => false option still not working as expected?
I expect that there will not be any timeout at all. That's very confusing.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Any issues with PDF rendering itself that are not directly related to this package, should be reported on https://github.com/KnpLabs/snappy instead. When having doubts, please try to reproduce the issue with just snappy.
If you believe this is an actual issue with the latest version of laravel-snappy, please reply to this issue so we can investigate further.
Thank you for your contribution! Apologies for any delayed response on our side.
Most helpful comment
@barryvdh just checked the
config/snappy.phpfile again because I'm configuring a new project.I think I've checked that the timeout is settable via the config file? :flushed:
I will check this soon...
EDIT:
Okay, I understand now.
If someone has a similar problem, you can set the timeout in the config: