mettle / sendportal

Open-source self-hosted email marketing. Manage your own newsletters at a fraction of the cost.
https://sendportal.io
MIT License
1.72k stars 339 forks source link

php artisan queue:work --queue=sendportal-message-dispatch this command is not working when run this command in my terminal it appears nothing and i also change QUEUE_CONNECTION=database but still nothing is showing #277

Open Rudrasingh11 opened 1 year ago

bmenking-wng commented 9 months ago

Just ran into this. When using QUEUE_CONNECTION=database, it appears those queues, sendportal-message-dispatch and sendportal-webhook-process, are not used by the software. I was able to get it working using

php artisan queue:work --queue=default

Hope this helps.

noehmeier commented 9 months ago

I set in .env the QUEUE_CONNECTION=database.

And i run:

php artisan queue:table
php artisan migrate

and i tried the following commands:

php artisan queue:work --queue=sendportal-message-dispatch
php artisan queue:work --queue=sendportal-webhook-process

php artisan queue:work --queue=default

But nothing happens with any of the queue:work command...

grafik

Any other recommondations how i can run a Campaign and not get stuck in "Queued"?

grafik

bmenking-wng commented 9 months ago

I set in .env the QUEUE_CONNECTION=database.

And i run:

php artisan queue:table
php artisan migrate

and i tried the following commands:

php artisan queue:work --queue=sendportal-message-dispatch
php artisan queue:work --queue=sendportal-webhook-process

php artisan queue:work --queue=default

But nothing happens with any of the queue:work command...

grafik

Any other recommondations how i can run a Campaign and not get stuck in "Queued"?

grafik

When you "sent" the campaign, did you select "Send Immediately" or "Queue draft" for sending behavior?

The other thing you can do is pull up the database and find the jobs (?) table. Look for a column "queue" and see what the name is. In my instance they are all going in as "default" but maybe yours is different?

noehmeier commented 9 months ago

Thank you for your fast response @bmenking-wng I tried both there, "Send automatically" and "Queue draft": grafik

but they are getting all "Queued" status: grafik

i have both tables jobs and failed_jobs, but they are always empty: grafik

Is that the problem, should there be entries in jobs?

bmenking-wng commented 9 months ago

Thank you for your fast response @bmenking-wng I tried both there, "Send automatically" and "Queue draft": grafik

but they are getting all "Queued" status: grafik

i have both tables jobs and failed_jobs, but they are always empty: grafik

Is that the problem, should there be entries in jobs?

So the issue I ran into was that incoming opens and click notifications from AWS SNS were not getting processed by the queue. I don't think email sending uses the queue, but I could be wrong.

Check to see if the cron job from the docs is running https://sendportal.io/docs/v2/getting-started/configuration-and-setup#additional-configuration

Under the Messages section if you click on the "Draft" tab you may see all the unsent email messages. Enabling that cron job should start pushing those "Send Immediately" messages out to the email provider that is configured.

noehmeier commented 9 months ago

Thank your very much @bmenking-wng for your hint with the cron job. The schedule:run did the job and all Campaigns have been sent out and i see the jobs in the jobs database table.

> php artisan schedule:run
[2023-12-20T23:22:32+00:00] Running scheduled command: Dispatch all campaigns waiting in the queue

I configure this for a friend and i found out he has just a simple webspace with PHP/MySQL and no SSH/cronjob access. I switched back to QUEUE_CONNECTION=sync and it seems like this also needs the cron job. But docs say:

The synchronous queue runs any queued jobs as they are requested, requiring the user to wait until the job has been completed before any further action can be taken.

For me it sounds like it sends the messages directly after saving the Campaign, why it needs then the cron job? Anyway, it looks like Sendportal is then not useable on a simple webspace? Maybe i open a new issue for this question...

bmenking-wng commented 9 months ago

Thank your very much @bmenking-wng for your hint with the cron job. The schedule:run did the job and all Campaigns have been sent out and i see the jobs in the jobs database table.

> php artisan schedule:run
[2023-12-20T23:22:32+00:00] Running scheduled command: Dispatch all campaigns waiting in the queue

I configure this for a friend and i found out he has just a simple webspace with PHP/MySQL and no SSH/cronjob access. I switched back to QUEUE_CONNECTION=sync and it seems like this also needs the cron job. But docs say:

The synchronous queue runs any queued jobs as they are requested, requiring the user to wait until the job has been completed before any further action can be taken.

For me it sounds like it sends the messages directly after saving the Campaign, why it needs then the cron job? Anyway, it looks like Sendportal is then not useable on a simple webspace? Maybe i open a new issue for this question...

If you cannot setup cron jobs then "sync" is what you would want. Most likely it processes queue jobs each time a page is loaded on the website. Had a project that operated this way and we used an external cron job to load the front page every two minutes so it would process queue jobs.

Another way to do this may be to create an API that kicks off queue jobs. That way an external cron could be used. This may get you in the direction of that solution: https://stackoverflow.com/questions/32124592/laravel-run-queue-work-from-code

noehmeier commented 9 months ago

Thank you again for your input @bmenking-wng.

Most likely it processes queue jobs each time a page is loaded on the website.

Yes, that is what i expected, too. I asked ChatGPT, it says the same:

[...] If you set QUEUE_CONNECTION=sync, you essentially disable the queue system, and the jobs will be processed synchronously as part of the web request. [...]

But nothing happens, i clicked every page of my Sendportal app, but the Campaigns keep Queued:

grafik

I also checked config/queue.php in my Laravel directory as you noticed in StackOverflow, but it looks also fine for me:

[...]
'default' => env('QUEUE_CONNECTION', 'sync'),
[...]
'connections' => [

        'sync' => [
            'driver' => 'sync',
        ],
[...]

I have no idea, what else i could do or what it could be? 🤷🏽‍♂️

deadlyanony commented 9 months ago

I also faced the same issue but found a way.

You need to create a schedule job in cpanel if you are working on hosting the panel and use this command your hosting path here/project main directory name/artisan sp:campaigns:dispatch

image

noehmeier commented 9 months ago

Thank you for your input @deadlyanony. Sadly, at this webspace are no scheduled tasks / cron jobs available. I can just add files over FTP, modifiy database over phpmyadmin or update php.ini settings.

Also i still dont understand why this is necessary if i choose SYNC - should it not send straight after i clicked the save-Campaign-button?