2011-08-30 8 views
1
나는 무작위 오류를 받고 있어요

: 이니셜 라이저에서레일 3 메일러의 errno :: ECONNRESET Gmail은

UserMailer.activation(@user).deliver 

내가 사용하는 SMTP 설정을 : 이메일을 보내려고 할 때

Errno::ECONNRESET (Connection reset by peer): 

내 Google Apps 계정 :

ActionMailer::Base.smtp_settings = { 
    :address    => "smtp.gmail.com", 
    :port     => 587, 
    :domain    => "mydomain.com", 
    :user_name   => "[email protected]", 
    :password    => "tylerspw", 
    :authentication  => "plain", 
    :enable_starttls_auto => true 
} 

가끔은 제대로 작동하지만 다른 경우에는이 오류가 발생합니다. 어떤 아이디어?

답변

3

이것은 제한 시간 초과 또는 초과 서버로드와 같이 간단 할 수 있습니다. 예외를 구제하고 재시도를 제안한 다음 특정 횟수의 재 시도 후에 오류를 기록하고 실패 (또는 다른 사람에게 통보) 할 것을 제안합니다. 이 줄의 어떤 것

tries = 0 
begin 
    UserMailer.activation(@user).deliver 
rescue Errono::ECONNRESET => e 
    if (tries += 1) > 2 
    retry 
    else 
    # log error 
    end 
end 
+0

나쁘지 않은 생각. – tybro0103