symfony: Symfony\Component\Process\Process Bug in Windows Server

I’m using the wkhtmltopdf.exe command line program to generate PDF from HTML I’m using it through Knp/Snappy package which is using Symfony\Component\Process\Process to run the program in the cmd. It works fine in my computer (Win 8.1 64bit and Win 7 32bit) but not in the deployment machine (Windows Server 2012 R2, 12GB, Intel Xeon 2.4 Ghz)

here is the code using Process class:

$binary = \Config::get('snappy.pdf.binary');
    $process = new Symfony\Component\Process\Process($binary.' http://localhost/gca/public/demandes-achat/1138/pdf processs.pdf');
    $process->run(function ($type, $buffer) {
        if (\Symfony\Component\Process\Process::ERR === $type) {
            echo 'ERR > '.$buffer;
        } else {
            echo 'OUT > '.$buffer;
        }
    });

I get a 60 seconds timeout error:

Symfony\Component\Process\Exception\ProcessTimedOutExceptionGET /gca/public/test
The process "C:\xampp\htdocs\gca/wkhtmltopdf/bin/wkhtmltopdf.exe http://localhost/gca/public/demandes-achat/1138/pdf process.pdf" exceeded the timeout of 60 seconds

Knowing that wkhtmltopdf is working as expected using the windows cmd, I tried to use the the native PHP function exec() and it worked fine ! From this, I noticed that there is a problem with the Process class.

I opened an issue in the Knp/Snappy reposetory, it may help: https://github.com/KnpLabs/snappy/issues/169

Thank you

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 20 (15 by maintainers)

Most upvoted comments

Just set the timeout you want to use in the Process constructor:

For example for 42s timeout: $process = new Symfony\Component\Process\Process($binary.' http://localhost/gca/public/demandes-achat/1138/pdf processs.pdf', null, null, null, 42); or after object creation:

$process = new Process(...);
$process->setTimeout(42);

Use a timeout of 0 to disable timeout, see doc http://symfony.com/doc/current/components/process.html#process-timeout