Error : Exit with code 1 due to network error: ConnectionRefusedError #3244

Open
eved42 opened this Issue Dec 9, 2016 · 1 comment

Projects

None yet

1 participant

@eved42
eved42 commented Dec 9, 2016 edited

Hello,

I use wkhtmltopdf in a Symfony3 project with KnpSnappyBundle.

It worked well until now on my local PC, but when I put it on my Windows Server 2008 R2 Standard, I had this error : Exit with code 1 due to network error: ConnectionRefusedError

It seems the PDF generation works well but there's something wrong at the end...

Log :

The exit status code '1' says something went wrong:
stderr: "Loading pages (1/6)
[> ] 0%
[======> ] 10%
[==========> ] 18%
[================> ] 27%
[==================> ] 30%
[====================> ] 34%
[=====================> ] 36%
[=====================> ] 36%
[=======================> ] 39%
[==================================> ] 58%
[=====================================> ] 63%
[=======================================> ] 66%
[=============================================> ] 76%
[================================================> ] 80%
[===================================================> ] 86%
[====================================================> ] 88%
[=====================================================> ] 89%
[=====================================================> ] 89%
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[===============> ] Page 1 of 4
[==============================> ] Page 2 of 4
[=============================================> ] Page 3 of 4
[============================================================] Page 4 of 4
Done
Exit with code 1 due to network error: ConnectionRefusedError
"
stdout: ""
command: C:\wamp64\www\products\app/../vendor/wemersonjanuario/wkhtmltopdf-windows/bin/64bit/wkhtmltopdf.exe --lowquality --image-quality "80" --margin-bottom "5mm" --margin-left "5mm" --margin-right "5mm" --margin-top "5mm" --user-style-sheet "C:\wamp64\www\products\app/../web/assets/css/model-pdf.css" --viewport-size "1200x1697" "se27applinet2.thuasne.fr/products/web/app_dev.php/models/preview/LBMUM/pdf" "C:\Windows\TEMP\knp_snappy584a75d83e48f4.11773527.pdf".

config.yml

knp_snappy:
    pdf:
        enabled: true
        binary: %kernel.root_dir%/../vendor/wemersonjanuario/wkhtmltopdf-windows/bin/64bit/wkhtmltopdf.exe
        options:
           #orientation: Landscape
           viewport-size: 1200x1697
           image-quality: 80
           margin-left: 5mm
           margin-right: 5mm
           margin-top: 5mm
           margin-bottom: 5mm
           user-style-sheet: %kernel.root_dir%/../web/assets/css/model-pdf.css

Controller

 /**
  * @Route("/models/pdf/{code}", name="model_pdf")
  */
  public function pdfAction($code, Request $request) {
      // get model from database
      $em = $this->getDoctrine()->getManager();
      $model = $em->getRepository('AppBundle:Model')->find($code);

      // model doesn't exist
      if (!$model) {
         throw $this->createNotFoundException('No model found for code '. $code);
      }

      $url = $request->server->get('HTTP_HOST');
      $url .= $this->generateUrl('model_preview', array(
		"code" => $code,
		"pdf"	 => "pdf"
      ));

      return new Response(
		$this->get('knp_snappy.pdf')->getOutput($url),
		200,
		array(
		    'Content-Type'          => 'application/pdf',
		    'Content-Disposition'   => 'attachment; filename="' . $code . '.pdf"'
		)
	);
   }

Maybe the problem is that it can't open the PDF ?
I have no problem in local.

Thanks for your help !

EDIT:
With the server admin, we changed the temporary folder to be sure to have permissions on the folder.
He changed the user rights but we still have the same error...

# config.yml
knp_snappy:
    temporary_folder: %kernel.root_dir%/../var/tmp

It seems the temporary file is created but delete just after. The server admin see it and it desappears quickly.
Any idea ?

@eved42
eved42 commented Dec 19, 2016

Please help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment