framework: When running as daemon worker, there are SSL errors when attempting to send email
I upgraded from 4.1 to 4.2.
Running as queue:work would create SSL errors, but not when running queue:listen.
Using smtp driver with mailgun as the host.
[2014-06-04 02:26:19] production.ERROR: exception 'ErrorException' with message 'fwrite(): SSL operation failed with code 1. OpenSSL Error messages:
error:1409F07F:SSL routines:SSL3_WRITE_PENDING:bad write retry' in /var/www/app.dev/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:236
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'fwrite(): SSL o...', '/var/www/queues...', 236, Array)
#1 /var/www/app.dev/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(236): fwrite(Resource id #3337, 'MAIL FROM: <con...')
#2 /var/www/app.dev/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php(175): Swift_Transport_StreamBuffer->_commit('MAIL FROM: <con...')
#3 /var/www/app.dev/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php(92): Swift_ByteStream_AbstractFilterableInputStream->_doWrite('MAIL FROM: <con...')
...
#30 /var/www/app.dev/artisan(59): Symfony\Component\Console\Application->run()
#31 {main} [] []
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 31 (12 by maintainers)
I think closing the connection after sending an email would be the correct way to fix this. At least it sounds more sane than trying to close the connection before sending an email and calling that a forced reconnection.
As @drcreazy’s solution seems to work I’ve submitted a corresponding pull request for the 5.1 branch (see https://github.com/laravel/framework/pull/13583). If approved I’ll submit the the changes for 5.0 and 5.2 as well.
Well, I tested all solutions include described in this thread
Seems the only appropriate solution is stopping transport after each task (it’s looks like the transport connects automatically on next task):
I tried to reset daemons after couple failed attempts, but after some time I got timeouts errors from mailgun so it didn’t help me.
This is all my code for the job handler (worked fine in prod for a week, php7). Catching errors/stopping daemon instance seems unnecessary, but I keep it for now (hope they can helps somebody) :
I had to restart every 15 min and seems to have been a good temp fix.