laravel 队列守护进程邮件因 SSL 错误而停止运行

Posted

技术标签:

【中文标题】laravel 队列守护进程邮件因 SSL 错误而停止运行【英文标题】:laravel queue daemon mail stops functioning with SSL error 【发布时间】:2014-09-22 15:13:39 【问题描述】:

我正在运行一个 laravel 队列守护程序,它根据所采取的操作发送邮件。这是通过主管运行以确保它始终运行。起初它工作正常,但一段时间后邮件停止发送。该错误未报告链上,但日志显示:

[2014-07-30 20:00:21] 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 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php:232
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'fwrite(): SSL o...', '/srv/www/example...', 232, Array)
#1 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php(232): fwrite(Resource id #376, 'MAIL FROM: <hel...')
#2 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php(171): Swift_Transport_StreamBuffer->_commit('MAIL FROM: <hel...')
#3 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/AbstractFilterableInputStream.php(90): Swift_ByteStream_AbstractFilterableInputStream->_doWrite('MAIL FROM: <hel...')
#4 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(274): Swift_ByteStream_AbstractFilterableInputStream->write('MAIL FROM: <hel...')
#5 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(243): Swift_Transport_AbstractSmtpTransport->executeCommand('MAIL FROM: <hel...', Array, Array)
#6 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/EsmtpTransport.php(323): Swift_Transport_EsmtpTransport->executeCommand('MAIL FROM: <hel...', Array)
#7 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(416): Swift_Transport_EsmtpTransport->_doMailFromCommand('hello@example.co...')
#8 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(444): Swift_Transport_AbstractSmtpTransport->_doMailTransaction(Object(Swift_Message), 'hello@example.co...', Array, Array)
#9 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php(174): Swift_Transport_AbstractSmtpTransport->_sendTo(Object(Swift_Message), 'hello@example.co...', Array, Array)
#10 /srv/www/example.co.uk/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mailer.php(85): Swift_Transport_AbstractSmtpTransport->send(Object(Swift_Message), Array)
#11 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(328): Swift_Mailer->send(Object(Swift_Message), Array)
#12 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Mail/Mailer.php(150): Illuminate\Mail\Mailer->sendSwiftMessage(Object(Swift_Message))
#13 /srv/www/example.co.uk/bootstrap/compiled.php(3231): Illuminate\Mail\Mailer->send('emails.campaign...', Array, Object(Closure))
#14 /srv/www/example.co.uk/app/commands/Sender.php(252): Illuminate\Support\Facades\Facade::__callStatic('send', Array)
#15 /srv/www/example.co.uk/app/commands/Sender.php(252): Illuminate\Support\Facades\Mail::send('emails.campaign...', Array, Object(Closure))
#16 /srv/www/example.co.uk/app/commands/Sender.php(116): Sender->_sendEmail(Array, Array, Array, Array)
#17 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php(96): Sender->queue(Object(Illuminate\Queue\Jobs\RedisJob), Array)
#18 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Jobs/RedisJob.php(46): Illuminate\Queue\Jobs\Job->resolveAndFire(Array)
#19 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(192): Illuminate\Queue\Jobs\RedisJob->fire()
#20 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(142): Illuminate\Queue\Worker->process('redis', Object(Illuminate\Queue\Jobs\RedisJob), '2', 0)
#21 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(101): Illuminate\Queue\Worker->pop('redis', NULL, 0, '3', '2')
#22 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(73): Illuminate\Queue\Worker->runNextJobForDaemon('redis', NULL, 0, '3', '2')
#23 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(98): Illuminate\Queue\Worker->daemon('redis', NULL, 0, 128, '3', '2')
#24 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(68): Illuminate\Queue\Console\WorkCommand->runWorker('redis', NULL, 0, 128, true)
#25 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Console/Command.php(112): Illuminate\Queue\Console\WorkCommand->fire()
#26 /srv/www/example.co.uk/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(252): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#27 /srv/www/example.co.uk/vendor/laravel/framework/src/Illuminate/Console/Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#28 /srv/www/example.co.uk/vendor/symfony/console/Symfony/Component/Console/Application.php(887): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#29 /srv/www/example.co.uk/vendor/symfony/console/Symfony/Component/Console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Queue\Console\WorkCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#30 /srv/www/example.co.uk/vendor/symfony/console/Symfony/Component/Console/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#31 /srv/www/example.co.uk/artisan(59): Symfony\Component\Console\Application->run()
#32 main [] []

我的想法很糟糕?我正在使用 sendgrid 进行邮件发送

编辑,与此处相同:https://github.com/swiftmailer/swiftmailer/issues/490

【问题讨论】:

这个问题似乎离题了,因为它与编程无关。请参阅帮助中心的What topics can I ask about here。也许Server Fault 或Webmaster Stack Exchange 会是一个更好的提问地点。 不知道还有什么比编程错误的堆栈跟踪更多的编程,但没关系 【参考方案1】:

这是 Laravel/Swift 内部的一个错误,它处理它的方式是在长时间运行的队列工作者中的套接字。避免此问题的最佳方法是确保在发送每封电子邮件后关闭传输。

在 Laravel 的错误跟踪器中有一个 closed issue,它有几个 Laravel 代码库的补丁可以解决这个问题。

或者,查看YOzaz/Laravel-SwiftMailer 包,它具有更新的邮件外观,很可能会解决您遇到的问题。

【讨论】:

以上是关于laravel 队列守护进程邮件因 SSL 错误而停止运行的主要内容,如果未能解决你的问题,请参考以下文章

Laravel Artisan CLI 安全地停止守护进程队列工作者

如果工人作为守护进程运行,Laravel 排队的作业不会出现在新的遗物中

500内部错误Laravel,通过websocket守护进程获取图像

在 Laravel 中使用 TLS 配置电子邮件 - 错误 SSL 操作失败,代码 1 [重复]

带有队列 550 错误的 Laravel 电子邮件(每秒电子邮件太多)

守护进程,锁,队列(生产者消费者模型)