Error on sending multiple invoices

Error when selecting multiple invoices and going to Actions > Email Invoice

TimeoutException after 0:00:30.000000: Future not completed

It looks like they are actually being sent, however. So i’m not sure what to do with this notice.

Hi,

Other users have reported disabling attach PDF may help.

cc @david

To avoid opening another issue, I will report my related experience here.

I also encountered this error (30s timeout), but in my case the emails are clearly not being sent. Also, in Email settings the attach PDF was OFF by default and I never enabled it. Any thoughts on that?

Are there any errors in the logs?

Not sure I follow, I think the feature is disabled by default.

No errors in the laravel.log file.

Yes, it’s disabled by default. And I never changed this setting.

Do you see this error if you send a single invoice?

I see this error upon the “Resend invitation” action for the new user.

BTW, should those emails be sent immediately or per the cron job setting? I set the cron to trigger once per hour

Maybe that’s the problem, the cron should be set to run every minute

https://invoiceninja.github.io/docs/self-host-installation/#cron-configuration

Even if that’s true, this is a “30 seconds timeout” error. Less than one minute.

Is there a reason you’re running the cron every hour rather than every minute?

@david do you have any thoughts to debug the problem

No reason. I didn’t understand the aforementioned part of the docs as a “must”, but more as an example. Besides, there’s not a single mentioning of 1 minute repetition, but 5 minutes and that’s for a case when one would set the QUEUE_CONNECTION=database within the .env file, but my setting is QUEUE_CONNECTION=sync.


You will then need to update the QUEUE_CONNECTION variable in the .env file as follows:

QUEUE_CONNECTION=database

If you are on shared hosting, it is possible to get the queues working by defining a new cron with the following configuration:

*/5 * * * * cd  /path/to/root/folder && /usr/bin/php -d register_argc_argv=On artisan queue:work --stop-when-empty

This cron will start a queue worker every 5 minutes and run any jobs that are in the queue and then gracefully terminate itself. This means any emails / notification may be queued for a small period of time prior to executing. If this amount of delay is acceptable, it is a great way to get queue’s working on shared hosting.

Does the QUEUE_CONNECTION=sync even work on a shared hosting?

All of the cron examples (excluding the last one) are * * * * *

The sync setting could explain the problem, have you tried database instead? With sync the app waits for the process to complete whereas with database the app can send the request and not wait for for the response.

I just made the following changes and it seems that one change (or perhaps all of them) did the trick:

QUEUE_CONNECTION=syncQUEUE_CONNECTION=database
MAIL_PORT=465MAIL_PORT=587

I added the two cron jobs exactly as per the docs below (every 1min. and 5min.):
https://invoiceninja.github.io/docs/self-host-installation/#cron-configuration

Then ran php artisan optimize and after another try, the emails start flowing.

Glad to hear it’s working!

I think there’s just one cron though, maybe it’s the same one running twice?

This one is running every 5 min:
php -d register_argc_argv=On artisan queue:work --stop-when-empty

the other one is running every minute:
php -d register_argc_argv=On artisan schedule:run

Should I keep only the first one?

Sorry for the confusion, I’m wrong. You have it correct.

1 Like