php - swiftmailer and Yii2 not working 1 out of 10 time -
i have background process sending email me when specific event occur. it's working of time (9 out of 10), sometime following error message :
php warning 'yii\base\errorexception' message 'fwrite(): ssl: established connection aborted software in host machine.' in e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\streambuffer.php:232 stack trace: #0 [internal function]: yii\base\errorhandler->handleerror(2, 'fwrite(): ssl: ...', 'e:\programdata\...', 232, array) #1 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\streambuffer.php(232): fwrite(resource id #481, 'mail from:<mte@...') #2 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\bytestream\abstractfilterableinputstream.php(171): swift_transport_streambuffer->_commit('mail from:<mte@...') #3 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\bytestream\abstractfilterableinputstream.php(90): swift_bytestream_abstractfilterableinputstream->_dowrite('mail from:<mte@...') #4 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\abstractsmtptransport.php(276): swift_bytestream_abstractfilterableinputstream->write('mail from:<mte@...') #5 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\esmtptransport.php(243): swift_transport_abstractsmtptransport->executecommand('mail from:<mte@...', array, array) #6 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\esmtptransport.php(322): swift_transport_esmtptransport->executecommand('mail from:<mte@...', array) #7 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\abstractsmtptransport.php(416): swift_transport_esmtptransport->_domailfromcommand('mte@...') #8 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\abstractsmtptransport.php(444): swift_transport_abstractsmtptransport->_domailtransaction(object(swift_message), 'mte@...', array, array) #9 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\abstractsmtptransport.php(176): swift_transport_abstractsmtptransport->_sendto(object(swift_message), 'mte@...', array, array) #10 e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\mailer.php(85): swift_transport_abstractsmtptransport->send(object(swift_message), array) #11 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2-swiftmailer\mailer.php(146): swift_mailer->send(object(swift_message)) #12 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\mail\basemailer.php(260): yii\swiftmailer\mailer->sendmessage(object(yii\swiftmailer\message)) #13 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\mail\basemessage.php(48): yii\mail\basemailer->send(object(yii\swiftmailer\message)) #14 e:\programdata\htdocs\yii2_kb\controllers\backgroundtask.php(172): yii\mail\basemessage->send() #15 e:\programdata\htdocs\yii2_kb\vendor\bazilio\yii2-async\commands\asyncworkercommand.php(29): app\controllers\backgroundtask->execute() #16 [internal function]: bazilio\async\commands\asyncworkercommand->actiondaemon('background') #17 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\base\inlineaction.php(55): call_user_func_array(array, array) #18 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\base\controller.php(151): yii\base\inlineaction->runwithparams(array) #19 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\console\controller.php(91): yii\base\controller->runaction('daemon', array) #20 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\base\module.php(455): yii\console\controller->runaction('daemon', array) #21 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\console\application.php(167): yii\base\module->runaction('async-worker/da...', array) #22 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\console\application.php(143): yii\console\application->runaction('async-worker/da...', array) #23 e:\programdata\htdocs\yii2_kb\vendor\yiisoft\yii2\base\application.php(375): yii\console\application->handlerequest(object(yii\console\request)) #24 e:\programdata\htdocs\yii2_kb\yii(23): yii\base\application->run() #25 {main} php warning: fwrite(): ssl operation failed code 1. openssl error messages: error:1409f07f:ssl routines:ssl3_write_pending:bad write retry in e:\programdata\htdocs\yii2_kb\vendor\swiftmailer\swiftmailer\lib\classes\swift\transport\streambuffer.php on line 232
here follow configuration mailer :
'mailer' => [ 'class' => 'yii\swiftmailer\mailer', 'transport' => [ 'class' => 'swift_smtptransport', 'host' => 'x.x.x.xxx', 'username' => 'xxx', 'password' => 'xyxyxy', 'port' => '25', 'encryption' => 'tls', ], ],
i'm using yii 2.0.6 php version : 5.5.9 mail server : exchange server 2010
when fail, it's after period of inactivity between 2 events ( few hours).
any ideas ?
thanks ineersa tips.
i've added following code in beginning of background process, , it's working.
if (yii::$app->mailer->gettransport()->isstarted()) { yii::$app->mailer->gettransport()->stop(); } yii::$app->mailer->gettransport()->start();
Comments
Post a Comment