Reputation: 5479
I'm working on my first Laravel app, and hit an odd problem when trying to queue up email sending using Mail::queue
to send emails.
I was originally using the sync
driver and everything worked fine, however having now switched over to the beanstalkd
driver it's stopped sending my emails.
My config is as follows:
apt-get
"pda/pheanstalk": "2.1.*"
in composer.json
What I've noticed is that every time I run
$ php artisan queue:work
I'm getting:
[ErrorException]
Insufficient data for unserializing - 2570 required, 168 present
queue:work [--queue[="..."]] [--delay[="..."]] [--force] [--memory[="..."]] [--sleep[="..."]] [--tries[="..."]] [connection]
I've tried selecting the redis
driver and that wasn't giving me the error, so clearly there is something wrong with how pheanstalk is running on my machine.
I've tried changing the pheanstalk version in composer.json
, but I'm still getting the same problem no matter which version I seem to use.
Problem is, this issue doesn't seem particularly widely documented, and the error message doesn't really give much away at all...
Any suggesions?
Upvotes: 5
Views: 1176
Reputation: 2049
Check this response: https://stackoverflow.com/a/28226746/1427439
You might be having the same issue.
Basically, make sure you're not using any Eloquent models with the closure you are passing to Mail::queue
Upvotes: 1
Reputation: 2149
You can not pass objects to the view data, because laravel can not serialize them correct, so you just need to change any data that is passed to the view to a simple data structure like array.
Upvotes: 0
Reputation: 1335
Laravel serializes and encrypts everything it pushes to a queue. Is your application encryption key (app/config/app.php 'key'
) set to a non-blank value?
Can you query beanstalkd yourself, to see what messages are getting pushed on to the queue? You should see incomprehensible strings like this:
eyJpdiI6IlZwT1p6QkhXQ3BcL0lRUmlHXC9maE8xT2o5Rk1BSUtMM0d5SlRoKzcrSGNLTT0iLCJ2YWx1ZSI6Im02N05LQzNPamNZSmVpTW5kXC80NnkyWEl0RUFMZHFiQXo0VnlNYUlLUUQzSzUrZHNIS2Vlb1kxWkpRS1VFZm5SVERXeHduWEFQelE5SCtZbVBwRmk2QkJPTlB5ek1RNWpKM3JRTzBDSlB3N3orYmk5UmZwM0ZzNmlpVVdQWVdQNWtKSWVQVG5nK29MajcyM3VtTUdraE5SNXJXYUJyYUErb25iTUJGSzhQYms9IiwibWFjIjoiNGFmNjMwNjYxYzk4NmMyZTA2ZTZlMzAwZTBlZjZhMTA1OGM2NzAxNTBkNWUzYTA2MTY3NzNiMTU4NTRlMmEyOSJ9
That error implies that the strings you're pushing are either not encrypted, or there's something that's stopping the job being pushed on to the queue halfway. If nothing else, you can search for the text of that Exception ("Insufficient data for unserializing") and it should yield a PHP file at vendor/pda/pheanstalk
that you can fiddle with to try understanding what's going on.
Upvotes: 0