ActionMailer “Net::ReadTimeout” when using Delayed Job with Rackspace “emailsrvr.com”

安稳与你 提交于 2019-12-12 14:32:17

问题


Edit: I'm using Rails 3.2.17 and Ruby 2.0.0p0

I've been having some issues with ActionMailer timing out on sending mail; See ActionMailer Timing out

After increasing the default Unicorn timeout to 2min (for testing) It completes in about 45 sec. I thought the best way to handle this would be to use Delayed Job, however, when DJ runs the deliver method it's timing out too. Stack trace below.

Is DJ the right tool for the job? Do I need to increase the timeout for DJ (I thought that I had read the default was 6 hours)? Any advice would be helpful.

DJ call:

NotificationsMailer.delay.access_granted(self).deliver

Stacktrace:

[Worker(host:myhost.local pid:37598)] Job Class#access_granted (id=20) FAILED (3 prior attempts) with Net::ReadTimeout: Net::ReadTimeout
   (0.3ms)  BEGIN
   (1.0ms)  UPDATE "delayed_jobs" SET "last_error" = 'Net::ReadTimeout
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/protocol.rb:158:in `rescue in rbuf_fill''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/protocol.rb:152:in `rbuf_fill''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/protocol.rb:144:in `readline''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:931:in `recv_response''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:554:in `block in do_start''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:941:in `critical''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:554:in `do_start''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:519:in `start''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/mail-2.5.4/lib/mail/network/delivery_methods/smtp.rb:112:in `deliver!''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/mail-2.5.4/lib/mail/message.rb:2129:in `do_delivery''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/mail-2.5.4/lib/mail/message.rb:232:in `block in deliver''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/actionmailer-3.2.17/lib/action_mailer/base.rb:415:in `block in deliver_mail''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/activesupport-3.2.17/lib/active_support/notifications.rb:123:in `block in instrument''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/activesupport-3.2.17/lib/active_support/notifications/instrumenter.rb:20:in `instrument''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/activesupport-3.2.17/lib/active_support/notifications.rb:123:in `instrument''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/actionmailer-3.2.17/lib/action_mailer/base.rb:413:in `deliver_mail''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/mail-2.5.4/lib/mail/message.rb:232:in `deliver''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/performable_mailer.rb:6:in `perform''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/backend/base.rb:105:in `block in invoke_job''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `execute''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/backend/base.rb:102:in `invoke_job''
(eval):3:in `block in invoke_job_with_newrelic_transaction_trace''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:339:in `perform_action_with_newrelic_trace''
(eval):2:in `invoke_job_with_newrelic_transaction_trace''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:206:in `block (2 levels) in run''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/timeout.rb:65:in `timeout''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:206:in `block in run''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:205:in `run''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:267:in `block in reserve_and_run_one_job''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `execute''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:267:in `reserve_and_run_one_job''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:189:in `block in work_off''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:188:in `times''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:188:in `work_off''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:153:in `block (4 levels) in start''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:152:in `block (3 levels) in start''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `execute''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:151:in `block (2 levels) in start''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:150:in `loop''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:150:in `block in start''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/plugins/clear_locks.rb:7:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:78:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:78:in `block (2 levels) in add''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:78:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:78:in `block in add''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `execute''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/worker.rb:149:in `start''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/delayed_job-4.0.0/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/task.rb:236:in `call''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/task.rb:236:in `block in execute''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/task.rb:231:in `each''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/task.rb:231:in `execute''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/task.rb:175:in `block in invoke_with_call_chain''
/Users/user/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/task.rb:168:in `invoke_with_call_chain''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/task.rb:161:in `invoke''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:149:in `invoke_task''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:106:in `block (2 levels) in top_level''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:106:in `each''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:106:in `block in top_level''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:115:in `run_with_threads''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:100:in `top_level''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:78:in `block in run''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:165:in `standard_exception_handling''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/lib/rake/application.rb:75:in `run''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/gems/rake-10.1.1/bin/rake:33:in `<top (required)>''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/bin/rake:23:in `load''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/bin/rake:23:in `<main>''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/bin/ruby_noexec_wrapper:14:in `eval''
/Users/user/.rvm/gems/ruby-2.0.0-p0@mysite/bin/ruby_noexec_wrapper:14:in `<main>''', "attempts" = 4, "run_at" = '2014-03-27 21:35:41.779268', "locked_at" = NULL, "locked_by" = NULL, "updated_at" = '2014-03-27 21:31:20.783344' WHERE "delayed_jobs"."id" = 20

回答1:


After trying dozens of different configs this is the one that finally worked:

config.action_mailer.smtp_settings = {
  address:              "secure.emailsrvr.com",
  port:                 465,
  domain:               "myapp.net",
  authentication:       :login,
  tls:                  true,
  user_name:            "no-reply@myapp.net",
  password:             "PASSWORD"
}

Additionally, in my Mailerclass, I had to make sure the default from was set to the same address as the user_name above.

EDIT To be clear, after implementing the above I no longer needed to use DJ



来源:https://stackoverflow.com/questions/22699768/actionmailer-netreadtimeout-when-using-delayed-job-with-rackspace-emailsrvr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!