Symfony 邮件程序:消息发送之间的 Swift_TransportException
在我目前正在工作的当前项目中,我有一个 symfony 任务,该任务将一些大量数据插入数据库并运行至少半个小时。 当任务开始时,邮件通知已正确发送,问题是在任务执行时我们无法发送另一封邮件来通知处理结束。
邮件程序工厂当前配置了假脱机传递策略,但在这种特定情况下,我们希望使用 sendNextImmediately() 方法立即触发通知。
我收到异常:
[Swift_TransportException]
预期响应代码为 250,但收到代码“451”,并显示消息“451 4.4.2 超时 - 关闭连接。74sm1186065wem.17” ”
以及 php 日志文件中的流动错误:
警告:fwrite():SSL:第 209 行 /var/www/project/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php 中的管道损坏
有人可以提供帮助吗? 有什么方法可以刷新 symfony 邮件程序以建立新连接吗?
On a current project which I'm currently working, i have a symfony task that runs some mass data insertion to database and runs it for at least half an hour.
When the task starts a mail notification is sent correctly, the problem is that at the of the task execution we can't send another mail to notify about the end of processing.
The mailer factory is currently configured with the spool delivery strategy but, in this specific situation, we desire to fire a notification immediately, using the sendNextImmediately() method.
I'm are getting the exception:
[Swift_TransportException]
Expected response code 250 but got code "451", with message "451 4.4.2 Timeout - closing connection. 74sm1186065wem.17
"
and the flowing error on php log file:
Warning: fwrite(): SSL: Broken pipe in /var/www/project/lib/vendor/symfony/lib/vendor/swiftmailer/classes/Swift/Transport/StreamBuffer.php on line 209
Can anyone give some help?
Is there any way that i can perhaps refresh symfony mailer to establish a new connection?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于 Symfony1 用户
我的猜测是连接保持时间太长(根本没有任何活动),导致 ssl 连接超时。
目前,可以通过在发送第二条消息之前停止 Swift_Transport 实例并再次显式启动它来解决该问题。
这是代码:
For Symfony1 Users
My guess was that the connection was being hold for too long (with no activity at all), causing an ssl connection timeout.
For now, the problem can be solved by stopping the
Swift_Transport
instance and starting it again explicitly, just before sending the second message.Here is the code:
我遇到了完全相同的问题,上述解决方案非常有帮助,但有一件事我必须做不同的事情:顺序。
如果我在发送消息之前尝试停止传输(连接超时已经挂起),它对我不起作用。另外,您不需要运行 getRealtimeTransport()->start() - 它会自动启动。
I had exactly the same problem and above solutions were very helpful, but there is one thing I had to do differently: order.
It didn't worked for me if I tried to stop Transport before sending message (connection timeout was already hanging). Also You don't need to run getRealtimeTransport()->start() - it will be started automatically.
在做Symfony2项目时,我也遇到过这个失败。我们使用的是永久运行的 php 脚本,这会产生错误。
我们发现以下代码可以完成这项工作:
Doing a Symfony2 project, I ran across this failure too. We were using a permanently running php script, which produced the error.
We figured out that following code does the job: