Lee Chambers's picture

Evening,

Have to say I'm rather disappointed with this release of invoice ninja v5.

After waiting for the best part of over a year for it to come to light it appears to have some underlining issues, that makes this appliance quite unusable. 

*PDF Generation does not seem to work when creating quotes, click PDF it just spins and loads nothing.

*The "TECH" invoice design does not load/work and displays an internal server error 500 

*Seems to be some conflict with NGINX and apache which has already been addressed before, question is .. is removing the nginx fix causing the issues with pdf generation.

Can not send any emails as the configuration window that only shows once to set smtp details does not seem to show at all as a percentage of the setup is precanned to turnkey linux after this there is no way to chance smtp details, which renders emailing from the application useless.

After such a wait for this appliance not just for myself but other users, there are quite alot of issues that has seemed to slip through any means of testing before release.

Forum: 
Lee Chambers's picture

Server healthcheck on the application shows errors out of the box.

any attempt to follow instructions on invoice ninja to change the settings in the .env file doesnt seem to work

running artisan optimize changes file permissions on certain files displayed in the healthcheck to not writable

snappdf appears to not be installed at all

issue with the queue system not running / working (issues with cronjobs)

after 7 hours of trying to get this appliance to work properly im at a loss and have no idea where to actually go from here other than to class the appliance as broken and unusable

Jeremy Davis's picture

It sounds like you've been having a fairly painful and disappointing time with the new appliance :( As I hinted in my other post, I think partially it is the requirements of the new Invoice Ninja version, but it also sounds like we could make some improvements.

Where do I find this "Server healthcheck" you speak of? I'd like to have a look myself and see what might be going on. I'm assuming that it's somewhere within the Invoice Ninja web UI but I've had a poke around and can't find it anywhere? Hopefully I'm not embarrassing myself too much and it's not too obvious...!

Re your issues running artisan, it sounds like you are running it as root, but not fixing permissions afterwards. You'll either need to run artisan as www-data (the webserver user) or fix permissions afterwards.

To fix permissions (you'll need to do this to fix where you're at - and re-run it everytime after running artisan commands):

chown -R www-dta:www-data /var/www/invoiceninja

And in future you can avoid having to fix permissions by running artisan commands via the www-data user like I did in my other post on this thread. I.e. like this:

runuser -l www-data -s /bin/bash -c "php /var/www/invoiceninja COMMAND"

(Where "COMMAND" is the actual command you want to run).

And yes re snappdf you are correct. We should probably pre-install that and use it locally (currently it leverages the public server). I'll look at doing that for the rebuild.

If you want to do that yourself, this should do the trick:

runuser -l -s /bin/bash -c "cd /var/www/invoiceninja && vendor/bin/snappdf download"
sed -i "\|^PDF_GENERATOR=|s|=.*|=snappdf|" /var/www/invoiceninja/.env
runuser -l www-data -s /bin/bash -c "php /var/www/invoiceninja/artisan optimize"
systemctl restart apache2

Also, I think that a TurnKey helper script for artisan might be a good idea (i.e. a simple wrapper script that will run "php artisan" as www-data).

Lee Chambers's picture

Hi if you log in to invoice ninja once logged in ... bottom left hand corner you will see a bold i (presumed to be information)

Click than and you will get a menu, in the there is the system healthcheck.

Unfortunately pdf will just not generate at all for me i have tried on a domain (even tho there is no where to actually set the domain on invoice ninja like in v4 where you put it in site) ive tried with ssl ive tried locally and just no joy.

Same as with emails, after editing thw env file and running artisan optimize after reinstating the correct permissions i would expect to see the values entered in the .env file listed under email settings such as reply to and send from etc but this remains blank.

Also when sending invoice it states "successfully added to queue" however this queue never seems to go any further which brings me to think the is an issue with the cron job.

Truth be told im at my wits end with it 

Jeremy Davis's picture

Ah ok, thanks. Yeah, I've found it.

Regarding that, I went through each one and addressed it. Here's some info:

I'm not sure what permissions were wrong, but running the following resolve it:

chown -R www-data:www-data /var/www/invoiceninja
find /var/www/invoiceninja -type d -exec chmod 755 {} \;

The PHP memory warning is also easy to fix (but we should have pre-set that correctly). Just bump 'memory_limit' to '512M' in /etc/php/8.1/apache2/php.ini:

sed -i "\|^memory_limit|s|=.*|= 512M|" /etc/php/8.1/apache2/php.ini
systemctl restart apache2

The message about "Queue not enabled" seems to be related to a setting that we probably should consider setting up by default. I'll need to read up a bit more on that as I'm assuming there must be some implications (they don't set it up by default, so there must be a reason why they don't do that).

However, I did double check that the cron job is working and have confirmed that it is. I set the cron job up to log what it does and most of the output is "INFO No scheduled commands are ready to run." each time it runs. Occasionally it will output something like this though:

  2022-11-21 02:20:01 Running [App\Jobs\Ninja\QueueSize] ............ 8ms DONE
  2022-11-21 02:20:01 Running [Callback] ........................... 11ms DONE

Which shows it's actually running. I'm guessing that I'd need to queue up some emails to test that part?


Regarding your experience and testing, when you say that you "tried on a domain" did you also use a "proper" SSL certificate? (E.g. generated via Let's Encrypt). Also, you shouldn't need to change any settings on your appliance to use a domain. So long as you have DNS set up (e.g. with an A record pointing to the IP address), just access your server via the domain.

I've already spent a few hours on this now and need to get back to updates. It sounds like you're pretty much done. Sorry to hear that it's been so painful for you. I'm not sure when I'll get around to it, but I'm hoping to circle back to this sometime soon - hopefully within the next day or 2.

The updated Invoice Ninja appliance certainly does appear to have been particularly problematic, but it's essentially a complete rewrite of Invoice Ninja. As so much has changed and it's now a much more complex app than it was, it's not super surprising that the first TurnKey release has a few rough edges. The Nginx bug is a big one that really shouldn't have got through testing, but hopefully we can soften some of these other ones really soon and re-release an improved v17.2 appliance.

Again sorry that you've had such a poor run with this. Thanks heaps for reporting though. I know it's really frustrating, but you sharing your experience is really helpful for us.

Jeremy Davis's picture

I've opened an issue on the tracker with some points to improve for the next release.

Jeremy Davis's picture

Hi Lee, thanks for sharing your feedback. I'm sorry to hear that it's not running how it should for you. We certainly did some preliminary testing and it all appeared to be working ok for us here. However, perhaps there are some intricacies?

Let me go through the issues you've noted and give you what I can see:

PDF Generation not working for Quotes

We definitely tested PDF generation and it was working fine. Having said that, we only tested PDF Invoice generation (which demonstrates that PDF generation actually functions).

I've launched an instance and will set it up shortly and double check the PDF generation myself. I'll initially test invoice because I know that should work. Then afterwards, I'll see if I can work out how to create a quote.

So out of interest, can you generate PDFs at all? If you can generate some PDFs but not others, then that suggests a deeper problem (not directly related to PDF generation). Please confirm whether Invoice PDF generation works or not?

I'll assume that creating a quote is straightforward? If so, after I've tested normal PDF generation, I'll have a go at seing if I can recreate the issue you're hitting?

[update] I reckon this might be also caused by CORS - see the 500 error just below).

"TECH" invoice design - 500 error

I can confirm this issue. I just tested and am hitting this same issue. I've had a quick poke around and it appears to be caused by a failing API call?

500 errors are caused by the back end not responding in an expected way. Invoice Ninja provides both the front and backend, so this doesn't make any sense to me.

I took a closer look and it appears that it may be a CORS issue. The API is served from the same domain and port as the main website, but a self-signed SSL certificate will still cause CORS errors.

To test my theory, I used Confconsole to get a free Let's Encrypt certificate (requires that the server is publicly available) and then it works fine!

Do you have your Invoice Ninja server set up with a domain and a "proper" SSL cert? Or are you just using the default self signed certificate? Unless you have a domain set up with a "proper" SSL cert, then that's the cause of the issue!

removing the nginx fix causing the issues with pdf generation?

It's possible, but highly unlikely. The only way that could have caused an issue with PDFs if it removed something that it shouldn't. When I tested it myself, it definitely didn't remove anything related to Apache or PHP, so should have zero impact. Note that in v4.x we preinstalled the PDF generation component. In v5.x Invoice Ninja bundles it's own PHP PDF generation library into the software.

Email configuration

By default, all TurnKey appliances have Postfix installed and configured as an MTA (mail transfer agent) to send mail directly. The default app config (Invoice Ninja in this case) is to leverage that. That should allow all TurnKey applications to send (but not receive) email OOTB. Having said that, in this day and age, sending emails directly is a very hit and miss process (mostly miss). Because of spammers abusing mail networks, unless you carefully configure things to reliably send email (far beyond the scope of this post) it's unlikely to be reliable.

The easiest solution is to just use Confconsole again to set up an SMTP mail relay. With that configured your sever should send out the emails no worries. Note that you will also get system emails that way too (such as installed security updates, etc).

Having said that, we didn't explicitly test Invoice Ninja v5 email sending for the final release (although it was tested earlier on in the v17.x update with INv5). I wouldn't have expected that to change, so IMO it should "just work". Perhaps it has changed, or perhaps we did something during development that caused a regression. When I get a chance, I'll set it up and double check that.

If you'd rather not get system emails and/or you just want to just (re)configure Invoice Ninja to use a remote SMTP server directly, then as you note, unfortunately Invoice Ninja doesn't provide UI options for that. I'm not really sure why they don't give that option (it's not how I would have done it) but it means that updating it isn't as easy as it should be IMO. You'll need to manually adjust the config file and run an artisan command to apply the updated config.

The config file that needs to be edited is /var/www/invoiceninja/.env. You need to update the relevant "MAIL_..." options. E.g. to use gmail:

MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=xxxx@gmail.com
MAIL_PASSWORD=xxxx
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=xxxx@gmail.com
MAIL_FROM_NAME=Admin

Note that if using Gmail, you also need to tweak the Gmail config settings to "allow insecure apps" to send emails from Invoice Ninja. I don't think there's anything there that I haven't noted, but Invoice Ninja troubleshooting docs have an email section which might help?

Then after updating the .env file, run the relevant artisan command as 'www-data' user:

runuser -l www-data -s /bin/bash -c "php /var/www/invoiceninja/artisan optimize"

And to be on the safe side, restart Apache:

systemctl restart apache2

Add new comment