设计邮件程序EOF错误

时间:2016-10-02 14:50:46

标签: ruby-on-rails ruby email ruby-on-rails-4 devise

我遇到了某种涉及Devise的回归错误,以及它在注册过程中向用户发送电子邮件的能力。我是Rails的新手,一旦我开始运行Devise,我就停止了对注册部分的试验。我最近升级了我的ruby版本,擦除了我的开发数据库,​​当我尝试重新创建一些用户时,我收到了这个错误:

Started POST "/users" for ::1 at 2016-10-02 09:32:34 -0400
Processing by DeviseInvitable::RegistrationsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"SFT9EQX83Aqg5jcdox1mLzlEGGRxUnvSngLgc08Hgysctg0BOI7Yrxv9UbWIjuS80Bf+hYHj0VA6B0LOMxTnLw==", "user"=>{"email"=>"user.name+test1@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
  User Load (154.7ms)  SELECT  `users`.* FROM `users` WHERE `users`.`email` = 'user.name+test1@gmail.com'  ORDER BY `users`.`id` ASC LIMIT 1
   (0.2ms)  BEGIN
  User Exists (3.3ms)  SELECT  1 AS one FROM `users` WHERE `users`.`email` = BINARY 'user.name+test1@gmail.com' LIMIT 1
  SQL (25.0ms)  INSERT INTO `users` (`email`, `encrypted_password`, `created_at`, `updated_at`, `confirmation_token`, `confirmation_sent_at`) VALUES ('user.name+test1@gmail.com', '$2a$10$20khSPmwRsCjxkiyjhiRE.BrYzV7Zu.6OY8rJnyLFB3Ju73PdLSLq', '2016-10-02 13:32:34', '2016-10-02 13:32:34', 'X2SBSZKmqTiV_As--ibW', '2016-10-02 13:32:34')
   (1.3ms)  COMMIT
  Rendered devise/mailer/confirmation_instructions.html.erb (1.0ms)

Devise::Mailer#confirmation_instructions: processed outbound mail in 173.1ms

Sent mail to user.name+test1@gmail.com (596.2ms)
Date: Sun, 02 Oct 2016 09:32:34 -0400
From: user.name@gmail.com
Reply-To: user.name@gmail.com
To: user.name+test1@gmail.com
Message-ID: <57f10c72dbcb5_c783ffd99fa77c0174cb@uname.ad.mdp.com.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Welcome user.name+test1@gmail.com!</p>

<p>You can confirm your account email through the link below:</p>

<p><a href="http://localhost:3000/users/confirmation?confirmation_token=X2SBSZKmqTiV_As--ibW">Confirm my account</a></p>

Completed 500 Internal Server Error in 1063ms (ActiveRecord: 184.5ms)

EOFError - end of file reached:
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:144:in `readline'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:945:in `recv_response'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:931:in `block in getok'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:955:in `critical'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:929:in `getok'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:830:in `helo'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:604:in `do_helo'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:556:in `do_start'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/smtp.rb:520:in `start'
  mail (2.6.4) lib/mail/network/delivery_methods/smtp.rb:113:in `deliver!'
  mail (2.6.4) lib/mail/message.rb:2149:in `do_delivery'
  mail (2.6.4) lib/mail/message.rb:237:in `block in deliver'
  actionmailer (4.2.3) lib/action_mailer/base.rb:543:in `block in deliver_mail'
  activesupport (4.2.3) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.3) lib/active_support/notifications.rb:164:in `instrument'
  actionmailer (4.2.3) lib/action_mailer/base.rb:541:in `deliver_mail'
  mail (2.6.4) lib/mail/message.rb:237:in `deliver'
  actionmailer (4.2.3) lib/action_mailer/message_delivery.rb:85:in `deliver_now'
  devise (4.2.0) lib/devise/models/authenticatable.rb:191:in `send_devise_notification'
  devise (4.2.0) lib/devise/models/confirmable.rb:117:in `send_confirmation_instructions'
  devise (4.2.0) lib/devise/models/confirmable.rb:179:in `send_on_create_confirmation_instructions'
  activesupport (4.2.3) lib/active_support/callbacks.rb:430:in `block in make_lambda'
  activesupport (4.2.3) lib/active_support/callbacks.rb:251:in `block in conditional'
  activesupport (4.2.3) lib/active_support/callbacks.rb:504:in `block in call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:504:in `call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:88:in `run_callbacks'
  activerecord (4.2.3) lib/active_record/transactions.rb:314:in `committed!'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:89:in `commit_records'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:153:in `commit'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:175:in `commit_transaction'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/transaction.rb:194:in `within_new_transaction'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/database_statements.rb:213:in `transaction'
  activerecord (4.2.3) lib/active_record/transactions.rb:220:in `transaction'
  activerecord (4.2.3) lib/active_record/transactions.rb:348:in `with_transaction_returning_status'
  activerecord (4.2.3) lib/active_record/transactions.rb:286:in `block in save'
  activerecord (4.2.3) lib/active_record/transactions.rb:301:in `rollback_active_record_state!'
  activerecord (4.2.3) lib/active_record/transactions.rb:285:in `save'
  devise (4.2.0) app/controllers/devise/registrations_controller.rb:17:in `create'
  actionpack (4.2.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.2.3) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.3) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.2.3) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.2.3) lib/active_support/callbacks.rb:115:in `call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:553:in `block (2 levels) in compile'
  activesupport (4.2.3) lib/active_support/callbacks.rb:503:in `call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:88:in `run_callbacks'
  actionpack (4.2.3) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.2.3) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.2.3) lib/active_support/notifications.rb:164:in `block in instrument'
  activesupport (4.2.3) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.2.3) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.3) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.2.3) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.2.3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.2.3) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.3) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.2.3) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.2.3) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.2.3) lib/action_controller/metal.rb:237:in `block in action'
  actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
  actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:45:in `serve'
  actionpack (4.2.3) lib/action_dispatch/routing/mapper.rb:49:in `serve'
  actionpack (4.2.3) lib/action_dispatch/journey/router.rb:43:in `block in serve'
  actionpack (4.2.3) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.3) lib/action_dispatch/routing/route_set.rb:821:in `call'
  warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
  warden (1.2.6) lib/warden/manager.rb:34:in `call'
  rack (1.6.4) lib/rack/etag.rb:24:in `call'
  rack (1.6.4) lib/rack/conditionalget.rb:38:in `call'
  rack (1.6.4) lib/rack/head.rb:13:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.3) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
  activerecord (4.2.3) lib/active_record/migration.rb:377:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:84:in `run_callbacks'
  actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
  web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.3) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.3) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.3) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
  actionpack (4.2.3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/static.rb:116:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.3) lib/rails/engine.rb:518:in `call'
  railties (4.2.3) lib/rails/application.rb:165:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

我正在使用gmail作为dev&amp; amp;的smtp服务器测试环境。这工作正常 - 我能够在&#39; user.name+test1@gmail.com'收到电子邮件; (早先在那个电子邮件地址的真实版本中)。

我无法从错误信息中准确理解问题所在。看起来Devise能够创建确认电子邮件:

Rendered devise/mailer/confirmation_instructions.html.erb (1.0ms)

然后似乎说电子邮件已发送

Devise::Mailer#confirmation_instructions: processed outbound mail in 173.1ms

Sent mail to user.name+test1@gmail.com (596.2ms)

但有些事情正在报告EOF错误。据推测,这是ruby的网络适配器抱怨它预计会发送更多文件(电子邮件数据?),但过早地用完了:

Completed 500 Internal Server Error in 1063ms (ActiveRecord: 184.5ms)

EOFError - end of file reached:
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:153:in `rbuf_fill'
  /Users/uname/.rvm/rubies/ruby-2.2.5/lib/ruby/2.2.0/net/protocol.rb:134:in `readuntil'

但这是我不会想到的事情之一自从Devise工作以来我改变了任何Devise配置或观点,所以我感到惊讶如果答案涉及改变现有的配置。

以前有没有经历过这样的事情?这篇文章似乎非常相似(Ruby mailer is coming up with an EOFError),但没有得到任何答复。

ALSO :我刚刚看到用户表中添加了一条记录,用于user.name+test1@gmail.com。那里有一个用于确认令牌的字段,当我从db中点击http://localhost:3000/users/confirmation?confirmation_token=[token时,用户已被确认,我可以使用它们登录。因此,此错误必须本地化为发送确认电子邮件(再次,从未到达我的收件箱)。

修改:这是我的邮件程序配置:

应用程序/配置/环境/ development.rb

Rails.application.configure do
  # Settings specified here will take precedence over those in config/application.rb.

  # In the development environment your application's code is reloaded on
  # every request. This slows down response time but is perfect for development
  # since you don't have to restart the web server when you make code changes.
  config.cache_classes = false

  # Do not eager load code on boot.
  config.eager_load = false

  # Show full error reports and disable caching.
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false

  # Don't care if the mailer can't send.
  config.action_mailer.raise_delivery_errors = false

  # Print deprecation notices to the Rails logger.
  config.active_support.deprecation = :log

  # Raise an error on page load if there are pending migrations.
  config.active_record.migration_error = :page_load

  # Debug mode disables concatenation and preprocessing of assets.
  # This option may cause significant delays in view rendering with a large
  # number of complex assets.
  config.assets.debug = true

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: Rails.application.secrets.email_provider_smtp_domain,
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: Rails.application.secrets.email_provider_username,
    password: Rails.application.secrets.email_provider_password
  }
  # ActionMailer Config
  config.action_mailer.default_url_options = { :host => 'localhost:3000' }
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.raise_delivery_errors = true
  # Send email in development mode?
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default :charset => "utf-8"

  # Asset digests allow you to set far-future HTTP expiration dates on all assets,
  # yet still be able to expire them through the digest params.
  config.assets.digest = true

  # Adds additional error checking when serving assets at runtime.
  # Checks for improperly declared sprockets dependencies.
  # Raises helpful error messages.
  config.assets.raise_runtime_errors = true

  # Raises error for missing translations
  # config.action_view.raise_on_missing_translations = true
end

0 个答案:

没有答案