标签: exception-notification

Rails Mailer"Net :: OpenTimeout:execution expired"仅限生产服务器上的异常

我在Ubuntu 12.04 TLS VPS上使用Ruby MRI 2.0.0和Rails 3.2.12,并尝试在我的应用程序中设置电子邮件通知.几天前工作正常,但现在不行了.我的网站主机是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
}
Run Code Online (Sandbox Code Playgroud)

使用RAILS_ENV=production rails console:

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
Run Code Online (Sandbox Code Playgroud)

输出:

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 …
Run Code Online (Sandbox Code Playgroud)

smtp ruby-on-rails actionmailer exception-notification

35
推荐指数
5
解决办法
3万
查看次数

如何让ExceptionNotifier在Rails 3中与delayed_job一起使用?

我希望ExceptionNotifier在延迟作业中发生异常时发送电子邮件,就像其他异常一样.我怎样才能做到这一点?

delayed-job ruby-on-rails-3 exception-notification

25
推荐指数
2
解决办法
6051
查看次数

exception_notification gem仅在Heroku生产模式下引发ActionView :: Template :: Error(未找到代码转换器(UTF-8到UTF-16))

我创建了部署在Heroku上的rails app.另外,exception_notification启用了gem.

当它在开发设置ActionMailer到Gmail时,一切正常并从Gmail地址发送通知.

但是当涉及到Heroku上的生产环境时,当服务器尝试发送电子邮件时,我会收到以下错误.

ActionView::Template::Error (code converter not found (UTF-8 to UTF-16))

谁能告诉我这里发生了什么?

ruby-on-rails heroku exception-notification

19
推荐指数
1
解决办法
2515
查看次数

rake任务中的Rails异常通知程序

我有一个简单的rails应用程序,带有一些控制器和一些rake任务.由gem配置的cron执行几个任务.

我的任务之一是每天执行,有时会引发异常,默认情况下我会收到cron的警告

rake aborted!
undefined method `parameterize' for nil:NilClass

Tasks: TOP => mailboxes:clean_processed
(See full trace by running task with --trace)
Run Code Online (Sandbox Code Playgroud)

我想调试正在发生的事情,因此我刚刚在我的这行中安装了这个异常通知 gemGemfile

gem "exception_notification", "~> 2.4.1", :require => 'exception_notifier'
Run Code Online (Sandbox Code Playgroud)

并在我的application.rb文件中配置它

# enable exception notification
config.middleware.use ExceptionNotifier,
                      :email_prefix => "[MyAppName] ",
                      :sender_address => %{"notifier" <report@example.com>},
                      :exception_recipients => %w{me@example.com}
Run Code Online (Sandbox Code Playgroud)

由于这个gem是一个机架中间件,它只适用于Web请求而不适用于rake任务.我也想为rake任务启用它,我找到了这个工作的要点.

它工作,但它不是DRY,我需要在该方法中重复gem配置,我还需要更改我所有的rake任务,将它们的语句封装在一个块中,如同

exception_notify { actual_task_code }
Run Code Online (Sandbox Code Playgroud)

有没有更好的方法来解决这个问题?

PS如果我需要更改通知gem不会有问题,因为我只为我的项目添加了几行代码.

PPS我知道我也可以更改crontab中的rake行来添加一个--trace选项,但是我不喜欢那个解决方案,导致异常通知程序imho是一个更好的解决方案,它也有助于Web代码.

更新我刚刚发现了这个相关的问题:delayed_not的exceptions_notification但两个答案都使用了类似的技巧.

我将尝试像Airbrake(以前称为hoptoad)或Exceptional这样的在线服务,但它们都是付费服务......

更新2:我尝试了Airbrake App,非常好的应用程序,但它遇到同样的问题,我仍然需要破解Rakefile来通知rake任务的异常.然而,hack不那么干,因为你只需要这个代码:

# notify exceptions …
Run Code Online (Sandbox Code Playgroud)

error-handling rake exception-handling ruby-on-rails exception-notification

15
推荐指数
3
解决办法
5021
查看次数

使用exception_notification在发生异常时发送电子邮件

我正在从rails 2.3迁移到rails 3.1,我正在尝试在生成异常时发送电子邮件.我正在使用exception_notification gem.

我剩下的电子邮件正在运行.但异常邮件不会被解雇.

以下是我的staging.rb文件中的设置.

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
Run Code Online (Sandbox Code Playgroud)

以下是application.rb中的代码

C::Application.config.middleware.use ExceptionNotification::Rack,
  :email => {
    :email_prefix => "[#{Rails.env.to_s.upcase} Error] ",
    :sender_address => %{"Exception Notifier " <email_id>},
    :exception_recipients => %w{email_id}
  }
Run Code Online (Sandbox Code Playgroud)

我不确定为什么电子邮件没有触发,也没有看到任何错误.任何帮助都会得到满足,谢谢.

ruby ruby-on-rails ruby-on-rails-3 exception-notification

6
推荐指数
1
解决办法
853
查看次数

ExceptionNotifier.notify_exception无法正常工作

我们正在使用这个gem(https://github.com/smartinez87/exception_notification)和rails 3.2.11.我们想从控制器的动作和wikie中提到的后台进程使用以下方法"ExceptionNotifier.notify_exception(e)"但是我们得到以下错误

ExceptionNotifier的未定义方法`notify_exception':Class

我们正在安装这个gem的3.0.1版本.gem"exception_notification","〜> 3.0.1"

我们的rails版本是3.2.11,ruby版本是ruby 1.9.2p320.

谢谢

ruby-on-rails exception-notification

5
推荐指数
1
解决办法
2981
查看次数

在开发中尝试exception_notification时ActionMailer :: Base :: NullMail

我想将exception_notification gem添加到我们的应用程序中,但是,当我尝试手动触发邮件时会发生这种情况:

exception
# => #<ZeroDivisionError: divided by 0>
ExceptionNotifier::Notifier.exception_notification(request.env, exception)
# => #<ActionMailer::Base::NullMail:0x007fa81bc7c610>
ExceptionNotifier::Notifier.background_exception_notification(exception)
# => #<ActionMailer::Base::NullMail:0x007fa81bf58190>
Run Code Online (Sandbox Code Playgroud)

在上面的示例中,在某个控制器中rescue_from Exception故意调用之后,控制台位于ApplicationController 内部的断点处1/0.

我也在使用delayed_job,但是 - 毫不奇怪 - ExceptionNotifier::Notifier.background_exception_notification(exception).deliver不会假装什么.

我已经设置config.consider_all_requests_local = false了开发,但仍然exception_notification实例化NullMail.在应用程序的其他部分,邮件工作正常并使用sendmail.

我在这里做错了什么想法?谢谢你的帮助!

ruby-on-rails ruby-on-rails-3 exception-notification exception-notifier

4
推荐指数
1
解决办法
5006
查看次数

Exception_Notification不知道RecordNotFound异常

我第一次尝试使用exception_notification.我观看了Railscast并遵循了作者在http://smartinez87.github.io/exception_notification/中的说明.一切似乎在某些例外情况下工作正常,但与其他情况不同.

我测试和错误,如收到的电子邮件错误notificatios从我的开发环境"An ActionView::Template::Error occurred in static_pages#home:."不过,也有一些例外,如RoutingExceptionRecordNotFound那些不被逮住ExceptionNotification,我不知道为什么,因为我没有任何rescue_from策略我的application_controller中的任何一种.

我正在使用rails 3.2.12并检查中间件堆栈数组,我可以看到ExceptionNotification只是最后一个,并且似乎某种异常不会在堆栈中出现,所以Exception Notification不知道他们.

所以,问题是:我做错了什么? ExceptionNotification 之间有什么区别ActionController::RoutingError或者ActiveRecord::RecordNotFound哪些不被捕获,ActionView::Template::Error哪些被捕获并导致异常通知将通知电子邮件发送到我的收件箱.

提前致谢

exception-handling ruby-on-rails rack-middleware exception-notification

1
推荐指数
1
解决办法
888
查看次数