500 Server Error - Viewing PDF and Creating Invoices on InvoiceNinja v5 Self Hosted

@Stevan

I think the issue is we haven’t updated packages for a very long time, i’ll need to consider pulling in the main package for all users so we don’t see this issue for users who cannot run composer install.

I think I recall reading from a post that the preferred way to update was to use the compressed files (I assume it was the source codes) and overwrite the files, not via the git pull method (and that was the method the internal updater currently used). Would you say that is still the case, I just have to run the composer command afterwards? Or I should try the git method? (FYSA, the internal updater was not working to update from 5.3.68 to 5.3.73, it gave a message box error and refreshed the page, without updating).

The compressed files are much smaller ~ 17mb, and are perfect for updates unless the subsystem cannot do composer install afterwards if the vendor packages have changed.

The nasty edge case we are seeing here is if composer install cannot run, the app breaks because the vendor packages are not available.

My thinking is we change this to point to the full package so whilst it is much larger, it improves to overall experience for all users.

I would avoid using git, we tried this previously and was not as reliable as this current method.

1 Like

Hi,
Thanks for this.
Overwriting with this file brought my site back to life, but PDF generation is still giving me a 500 Server Error.
I can confirm that both phantom as well as snappdf are causing this issue.
Further, even when I go to invoice design (HTML), it does not generate.
So I think it is an issue with the app itself, not the pdf engines.

I guess I have the same problem.
5.3.73 gives me an endless loading loop.

Will do a complete new install and report back if the problem is still there.

Update: After making a fresh install on a Ubuntu VM, the PDF problem is gone.

I wanted to report what happened lastnight.

I tried to copy over the previous copies. That was very unsuccessful. I have to do a complete new install.

Here was my steps:

Download with wget the zip file for the latest release.
Extracted in to /var/www/html
I had to run composer install -o --no-dev
Then I copied .env.example to .env
Then I created a key with artsian
Then I chown -R www-data:www-data .

Setup screen came up. It was an endless loop of the setup screen. So I manually made the .env file. There was no errors. I got in. Database still worked from 68 version. Client was working and all the other function was working except for PDF. It did matter if I use snappdf or phantomjs. I keep getting this error. Why is it calling localhost if that is not the app_url you place? This is where I am now. I can migrate again if you like to see what happens. But PDF are not working.

[2022-03-18 08:29:37] production.ERROR: file_get_contents(http://localhost/storage/JcwYAp1c9bp1jNC6mjWbA8RrCeBcPgZu/PViO2gZALI4ZiGVMSSTvKQuXvAespHtLFLXgIjsY.png): failed to open strea>
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError()
#1 /var/www/html/app/Models/Presenters/CompanyPresenter.php(69): file_get_contents()
#2 /var/www/html/app/Utils/HtmlEngine.php(419): App\\Models\\Presenters\\CompanyPresenter->logo_base64()
#3 /var/www/html/app/Utils/HtmlEngine.php(567): App\\Utils\\HtmlEngine->buildEntityDataArray()
#4 /var/www/html/app/Utils/TemplateEngine.php(175): App\\Utils\\HtmlEngine->generateLabelsAndValues()
#5 /var/www/html/app/Utils/TemplateEngine.php(147): App\\Utils\\TemplateEngine->entityValues()
#6 /var/www/html/app/Utils/TemplateEngine.php(84): App\\Utils\\TemplateEngine->replaceValues()
#7 /var/www/html/app/Http/Controllers/TemplateController.php(96): App\\Utils\\TemplateEngine->build()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\TemplateController->show()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#10 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(262): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#11 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Route.php(205): Illuminate\\Routing\\Route->runController()
#12 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Router.php(721): Illuminate\\Routing\\Route->run()
#13 /var/www/html/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#14 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php(127): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()

Can you try reuploading your company logo

1 Like

Yep. Hang on I will do it right now.

Yes that fixed the PDF. Why is the logo important? Is there something in the code that looks for a logo.

Unfortunately, uploading the company logo did not fix the PDF issue for me

@riggs498

The system needs to resolve the location of the PDF, if the URL changes, it will fail.

@david
So I did a migration and deleted the first company. No it will not show the logo. It shows uploaded. But that is it. PDF doesn’t work now. I ran the schedule:run and now things are a mess again. PDF will not load and just spins. No errors.

So the mobile app is working correctly. But the website is not. Weird.

try hard refresh Ctrl + F5

Are there any errors in the network tab in the browser console, maybe the image is failing to load?

@hillel
Yes there is an error.

I have the client portal working correctly. I shows the PDF and the logo. But if you look at the PDF in the invoice or hit view pdf it does not work.

Thanks, it looks like the app is trying to load the image using http.

Can you check that the APP_URL value in the .env file is using https?

Between everything I was trying. I must have forgot that and turn require_https back on. Learning lesson. Sorry! Maybe it helps someone else

My App URL value is set correctly, and so does my company have a logo. Still pdf generation does not seem to be working for me. Anything else we can do to troubleshoot?