Unable to preview or download PDFs

Hi folks,

Firstly, my setup is stock standard dockerfiles, with basic configuration. Has been running for 12 months within a Ubuntu WSL2 (windows 10 host machine)

For the past couple of months (and over several updates) I have been running into a problem with not being able to preview or download pdfs of invoices (using browser or windows app). The pdf preview seems to timeout.

The problem has been getting more frequent, so thought I would ask for help from the community.

The following is a snapshot of logs when I attempt to open an existing invoice:

log snapshot (taken from dockerfiles-server-1 nginx)

2023-03-01 14:36:50 2023/03/01 06:36:50 [error] 22#22: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.19.0.1, server: _, request: "POST /api/v1/live_preview?entity=invoice&entity_id=7N1aMnAbWm HTTP/1.1", upstream: "fastcgi://172.19.0.3:9000", host: "invoice.localhost.test", referrer: "http://invoice.localhost.test/"
log snapshot (taken from dockerfiles-app-1 invoiceninja/invoiceninja:5 )

2023-03-01 14:36:50 172.19.0.4 -  01/Mar/2023:06:35:49 +0000 "POST /index.php" 500
2023-03-01 14:36:50 2023-03-01 06:36:50,777 INFO reaped unknown pid 71 (exit status 0)
2023-03-01 14:36:50 2023-03-01 06:36:50,777 INFO reaped unknown pid 72 (exit status 0)
2023-03-01 14:36:50 2023-03-01 06:36:50,777 INFO reaped unknown pid 114 (exit status 0)
2023-03-01 14:36:50 2023-03-01 06:36:50,777 INFO reaped unknown pid 93 (exit status 0)
2023-03-01 14:36:50 2023-03-01 06:36:50,777 INFO reaped unknown pid 86 (exit status 0)
2023-03-01 14:37:00    INFO  No scheduled commands are ready to run.  

I’ve search multiple forum posts and other sites, however, there doesn’t seem to be any express solution.

The following is a bit advanced for me, as I am not sure where specifically to apply the changes.
https://forum.invoiceninja.com/t/v5-self-hosted-slow-to-save-runs-pdf-gen-multiple-times/9763

Thank you.

Kind regards,

Hi,

@david do you have any suggestions?

Thought I would add my .env and .yml

# IN application vars
APP_URL=http://invoice.localhost.test
APP_KEY=base64:REDACTED
APP_DEBUG=false
REQUIRE_HTTPS=false
PHANTOMJS_PDF_GENERATION=false
PDF_GENERATOR=snappdf
SNAPPDF_CHROMIUM_PATH=/usr/bin/chromium
LOG_PDF_HTML=true
QUEUE_CONNECTION=database
LOCAL_DOWNLOAD=true
IS_DOCKER=true
NINJA_ENVIRONMENT=selfhost

# DB connection
DB_HOST=db
DB_PORT=3306
DB_DATABASE=ninja
DB_USERNAME=REDACTED
DB_PASSWORD=REDACTED

# Create initial user
# Default to these values if empty
# IN_USER_EMAIL=admin@example.com
# IN_PASSWORD=changeme!
IN_USER_EMAIL=REDACTED
IN_PASSWORD=REDACTED

# Mail options
MAIL_MAILER=log
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS='user@example.com'
MAIL_FROM_NAME='Self Hosted User'

# MySQL
MYSQL_ROOT_PASSWORD=REDACTED
MYSQL_USER=ninja
MYSQL_PASSWORD=REDACTED
MYSQL_DATABASE=REDACTED

# V4 env vars
# DB_STRICT=false
# APP_CIPHER=AES-256-CBC

version: '3.7'

services:
  server:
    image: nginx
    restart: always
    env_file: env
    volumes:
      # Vhost configuration
      #- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com
      - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
      - ./docker/app/public:/var/www/app/public:ro
    depends_on:
      - app
    # Run webserver nginx on port 80
    # Feel free to modify depending what port is already occupied
    ports:
      - "80:80"
      #- "443:443"
    networks:
      - invoiceninja
    extra_hosts:
      - "in5.localhost:192.168.0.124 " #host and ip

  app:
    image: invoiceninja/invoiceninja:5
    env_file: env
    restart: always
    volumes:
      - ./config/hosts:/etc/hosts:ro
      - ./docker/app/public:/var/www/app/public:rw,delegated
      - ./docker/app/storage:/var/www/app/storage:rw,delegated
    depends_on:
      - db
    networks:
      - invoiceninja
    extra_hosts:
      - "in5.localhost:192.168.0.124 " #host and ip

  db:
    image: mysql:5
#    When running on ARM64 use MariaDB instead of MySQL
#    image: mariadb:10.4
#    For auto DB backups comment out image and use the build block below
#    build:
#      context: ./config/mysql
    ports:
      - "3305:3306"
    restart: always
    env_file: env
    volumes:
      - ./docker/mysql/data:/var/lib/mysql:rw,delegated

      # remove comments for next 4 lines if you want auto sql backups
      #- ./docker/mysql/bak:/backups:rw
      #- ./config/mysql/backup-script:/etc/cron.daily/daily:ro
      #- ./config/mysql/backup-script:/etc/cron.weekly/weekly:ro
      #- ./config/mysql/backup-script:/etc/cron.monthly/monthly:ro
    networks:
      - invoiceninja
    extra_hosts:
      - "in5.localhost:127.0.0.1 " #host and ip       

  # THIS IS ONLY A VALID CONFIGURATION FOR IN 4. DO NOT USE FOR IN 5.
  # cron:
  #   image: invoiceninja/invoiceninja:alpine-4
  #   volumes:
      # - ./docker/app/public:/var/www/app/public:rw,delegated
      # - ./docker/app/storage:/var/www/app/storage:rw,delegated
      # - ./docker/app/public/logo:/var/www/app/public/logo:rw,delegated
  #   entrypoint: |
  #     /bin/sh -c 'sh -s <<EOF
  #     trap "break;exit" SIGHUP SIGINT SIGTERM
  #     sleep 300s
  #     while /bin/true; do
  #       ./artisan ninja:send-invoices
  #       ./artisan ninja:send-reminders
  #       sleep 1d
  #     done
  #     EOF'
  #   networks:
  #     - invoiceninja
  #

networks:
  invoiceninja:

Update::

When opening an existing invoice within the WindowsApp, and navigate to ‘View PDF’ an error is thrown about and unable to view the pdf.

However, after performing the same steps, but within desktop Chromium browser, I am able to view preview of pdf within the invoice record, and I am able to View PDF from the PDF button.

I then go back to the WindowsApp and it is now working, however, only on the first instance.
If i navigate to another invoice record either in the app or desktop chromium browser, i am unable to see the preview or view pdf, however, no error is thrown in the App or web browser.

Thank you.

It sounds like your queues are not running, you can try running the app in sync mode

In your .env set

QUEUE_CONNECTION=sync

You may want to try configuring your queues, reference here:

Thank you, I appreciate it

That is working as intended.

I’ll have to look into setting up CRON so i can switch back to database mode.

Kind regards