Rails Mailer“ Net :: OpenTimeout:执行到期”仅在生产服务器上例外 [英] Rails Mailer "Net::OpenTimeout: execution expired" Exception on production server only
本文介绍了Rails Mailer“ Net :: OpenTimeout:执行到期”仅在生产服务器上例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Ubuntu 12.04 TLS VPS上使用Ruby MRI 2.0.0和Rails 3.2.12,并尝试在我的应用中设置电子邮件通知。 几天前运行良好,但现在不再工作了。我的网站托管服务器是OVH。
I am using Ruby MRI 2.0.0 and Rails 3.2.12 on a Ubuntu 12.04 TLS VPS and attempting to setup email notifications in my app. It was working fine a few days ago, but not anymore. My web host is OVH.
我的SMTP设置:
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => 'sender@gmail.com',
:password => 'secret',
:authentication => 'plain',
:enable_starttls_auto => true
}
使用 RAILS_ENV =生产导轨控制台
:
class MyMailer < ActionMailer::Base
def test_email
sender = "sender@gmail.com"
receiver = "receiver@example.com"
mail from: sender, to: receiver, subject: "Hello!", body: "World!!"
end
end
=> nil
MyMailer.test_email.deliver
输出:
Net::OpenTimeout: execution expired
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:540:in `initialize'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:540:in `open'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:540:in `tcp_socket'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:550:in `block in do_start'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:549:in `do_start'
from ~/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/net/smtp.rb:519:in `start'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/mail-2.4.4/lib/mail/message.rb:2034:in `do_delivery'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/mail-2.4.4/lib/mail/message.rb:229:in `block in deliver'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:415:in `block in deliver_mail'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `block in instrument'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/activesupport-3.2.12/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/activesupport-3.2.12/lib/active_support/notifications.rb:123:in `instrument'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/actionmailer-3.2.12/lib/action_mailer/base.rb:413:in `deliver_mail'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/mail-2.4.4/lib/mail/message.rb:229:in `deliver'
from (irb):28
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
from ~/.rvm/gems/ruby-2.0.0-p0@mygemset/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'2.0.0p0 :029 >
我尝试了以下操作:
-
exception_notification
宝石是几天前添加到设置中的。我试图在Gemfile
中注释其行及其匹配的配置,然后运行bundle install
。重新启动服务器后,即使删除并重新创建gemset,问题仍然存在。 - 在虚拟机上对其进行测试(与VPS完全相同的设置,包括iptables规则): 有效
- 禁用iptables规则:不起作用
- 从手动连接到Gmail使用openssl的VPS:可行(因此这不是防火墙问题-请参见此处:通过命令行连接到smtp.gmail.com );
- 在Gmail帐户选项中启用IMAP(已禁用):不起作用
- 使用其他Gmail帐户:不起作用
- 替换Ruby 2.0.0作者:Ruby 1.9.3
- 升级到Rails 3.2.13
- The
exception_notification
gem was added to the setup a few days ago. I tried to comment its line inGemfile
as well as its matching configuration, and runbundle install
. After restarting the server, the issue is still present, even if I delete and recreate the gemset. - Test it out on a virtual machine (exact same setup as the VPS including iptables rules): works
- Disable iptables rules: does not work
- Manually connect to Gmail from the VPS using openssl: works (so this is not a firewall issue - see here: Connecting to smtp.gmail.com via command line);
- Enable IMAP in Gmail account options (it was disabled): does not work
- Use a different Gmail account: does not works
- Replace Ruby 2.0.0 by Ruby 1.9.3
- Upgrade to Rails 3.2.13
有人可以
谢谢!
推荐答案
问题是由于生产服务器上的IPv6配置错误,现已解决。
The issue was due to an IPv6 misconfiguration on the production server and has now been fixed.
这篇关于Rails Mailer“ Net :: OpenTimeout:执行到期”仅在生产服务器上例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文