Snappdf download: Failed to open stream: Connection timed out in

Hello
I am trying to use snappdf. When trying to download, errors occur. Am I doing something wrong? Is there a solution/workaround for this?

root@invoice:/var/www/invoice/vendor/beganovich/snappdf# php snappdf download
PHP Warning:  file_get_contents(https://download-chromium.appspot.com/rev/Linux_x64?type=snapshots): Failed to open stream: Connection timed out in /var/www/invoice/vendor/beganovich/snappdf/src/Command/DownloadChromiumCommand.php on line 70
PHP Warning:  Attempt to read property "content" on null in /var/www/invoice/vendor/beganovich/snappdf/src/Command/DownloadChromiumCommand.php on line 73
Starting download. Revision:
PHP Warning:  fopen(https://download-chromium.appspot.com/dl/Linux_x64?type=snapshots): Failed to open stream: Connection timed out in /var/www/invoice/vendor/beganovich/snappdf/src/Command/DownloadChromiumCommand.php on line 87
Download completed. Extracting the zip archive.
Archive extracted.
PHP Warning:  chmod(): No such file or directory in /var/www/invoice/vendor/beganovich/snappdf/src/Command/DownloadChromiumCommand.php on line 105
Completed! -Linux_x64 currently in use.

Thanks for any help.
Regards, Michael

From the root of the invoice ninja project, try running this:

./vendor/bin/snappdf download --force

Thank you for your answer.

If I disable UFW on my Debian server then it works.

I have yet to figure out why the firewall is blocking this. The only thing I have configured is two ports open for incoming connections (80 and 443). As far as i know, by default, UFW is configured to deny all incoming traffic and allow all outgoing traffic.

I noticed that when I use file_get_contents, only requests with https are blocked, it works with http.

Receive data via https (not working)

php -r 'echo file_get_contents("https://download-chromium.appspot.com/rev/Linux?type=snapshots");'

Receive data via http (works)

php -r 'echo file_get_contents("http://eu.httpbin.org");'

I know this is off topic, but maybe it will help someone to understand who has a similar problem.

1 Like

@Michael
a6fb08fd8bc2eca035847777ef970f01

1 Like

did you get around to pinpoint the problem with ufw?
I’m running many docker containers behind caddy. And caddy is allowed to converse via 443/80. All work just fine.

But the invoice ninja is picky and still does something that results in

Failed to open stream: Connection timed out

I had the problem that I couldn’t download Snapdf on my vps when ufw was enabled. In order to download it I temporarily disabled the firewall. After download and installation of Snappdf I reactivated the firewall and the PDF views and files were generated. It’s been running fine for 9 months now.

This is all what i found i my own documentation:

Installing and configure SnapPDF as PDF Generator 
cd /var/www/invoiceninja
from the root of the project run:
vendor/bin/snappdf download 

After some time and errors:
Completed! -Linux_x64 currently in use. 

nano .env 
PDF_GENERATOR=snappdf 

php8.1 artisan optimize 
chown -R www-data:www-data /var/www/invoiceninja 

BTW: I’m not using docker containers. I installed InvoiceNinja on a Debian Linux VPS using git clone and Composer.

1 Like