无法弄清楚此错误的含义(rails Net::OpenTimeout:执行已过期)



我的rails应用程序出现错误:Net::OpenTimeout:执行已过期

我研究了这个错误,每个人都把它与Mailer联系起来,我认为这与我无关

/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878 in "initialize"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878 in "open"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:878 in "block in connect"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:877 in "connect"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:862 in "do_start"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:851 in "start"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/net/http.rb:1367 in "request"
/vendor/bundle/ruby/2.0.0/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51 in "request"
/vendor/bundle/ruby/2.0.0/gems/twilio-ruby-3.11.5/lib/twilio-ruby/rest/client.rb:216 in "connect_and_send"
/vendor/bundle/ruby/2.0.0/gems/twilio-ruby-3.11.5/lib/twilio-ruby/rest/client.rb:168 in "block (2 levels) in <class:Client>"
/vendor/bundle/ruby/2.0.0/gems/twilio-ruby-3.11.5/lib/twilio-ruby/rest/list_resource.rb:91 in "create"
/app/models/message.rb:52 in "send_sms"
/app/controllers/messages_controller.rb:91 in "block in api_send_message"
/app/controllers/messages_controller.rb:81 in "each"
/app/controllers/messages_controller.rb:81 in "api_send_message"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal/implicit_render.rb:4 in "send_action"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/abstract_controller/base.rb:189 in "process_action"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal/rendering.rb:10 in "process_action"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/abstract_controller/callbacks.rb:18 in "block in process_action"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/callbacks.rb:463 in "_run__4571876806874491795__process_action__callbacks"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/callbacks.rb:80 in "run_callbacks"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/abstract_controller/callbacks.rb:17 in "process_action"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal/rescue.rb:29 in "process_action"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal/instrumentation.rb:31 in "block in process_action"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/notifications.rb:159 in "block in instrument"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/notifications/instrumenter.rb:20 in "instrument"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/notifications.rb:159 in "instrument"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal/instrumentation.rb:30 in "process_action"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal/params_wrapper.rb:245 in "process_action"
/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.3/lib/active_record/railties/controller_runtime.rb:18 in "process_action"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/abstract_controller/base.rb:136 in "process"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/abstract_controller/rendering.rb:44 in "process"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal.rb:195 in "dispatch"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal/rack_delegation.rb:13 in "dispatch"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_controller/metal.rb:231 in "block in action"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:80 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:80 in "dispatch"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:48 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/journey/router.rb:71 in "block in call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/journey/router.rb:59 in "each"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/journey/router.rb:59 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/routing/route_set.rb:680 in "call"
/vendor/bundle/ruby/2.0.0/bundler/gems/omnicontacts-0338b3a3ee81/lib/omnicontacts/middleware/base_oauth.rb:41 in "call"
/vendor/bundle/ruby/2.0.0/bundler/gems/omnicontacts-0338b3a3ee81/lib/omnicontacts/builder.rb:27 in "call"
/vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35 in "block in call"
/vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34 in "catch"
/vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/etag.rb:23 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:35 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/params_parser.rb:27 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/flash.rb:241 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225 in "context"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/cookies.rb:486 in "call"
/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.3/lib/active_record/query_cache.rb:36 in "call"
/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:626 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/callbacks.rb:29 in "block in call"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/callbacks.rb:373 in "_run__2265971570262465834__call__callbacks"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/callbacks.rb:80 in "run_callbacks"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/callbacks.rb:27 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/remote_ip.rb:76 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/debug_exceptions.rb:17 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/show_exceptions.rb:30 in "call"
/vendor/bundle/ruby/2.0.0/gems/railties-4.0.3/lib/rails/rack/logger.rb:38 in "call_app"
/vendor/bundle/ruby/2.0.0/gems/railties-4.0.3/lib/rails/rack/logger.rb:20 in "block in call"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/tagged_logging.rb:67 in "block in tagged"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/tagged_logging.rb:25 in "tagged"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/tagged_logging.rb:67 in "tagged"
/vendor/bundle/ruby/2.0.0/gems/railties-4.0.3/lib/rails/rack/logger.rb:20 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/request_id.rb:21 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17 in "call"
/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.3/lib/active_support/cache/strategy/local_cache.rb:83 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/static.rb:64 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/sendfile.rb:112 in "call"
/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.3/lib/action_dispatch/middleware/ssl.rb:24 in "call"
/vendor/bundle/ruby/2.0.0/gems/railties-4.0.3/lib/rails/engine.rb:511 in "call"
/vendor/bundle/ruby/2.0.0/gems/railties-4.0.3/lib/rails/application.rb:97 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/lock.rb:17 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/content_length.rb:14 in "call"
/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60 in "service"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138 in "service"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94 in "run"
/vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295 in "block in start_thread"

它发生在我通过twilio发送短信时,只发生过一次。在此之前,我已经发送了6k条短信,没有任何问题。这不是问题吗?是什么原因造成的?

无法弄清楚这个错误意味着什么Net::OpenTimeout:执行已过期

这只是一个超时错误。当第三方服务器需要时间进行响应时,就会发生这种情况。

解决方案

  1. 后台作业中的第一个移动方法
  2. 在提出下一个请求时增加一些延迟。延迟取决于每秒对第三方服务器的呼叫能力或限制。sleep 5在大多数情况下是有效的
  3. 如果可能,请发出batch请求

参考文献

  1. 每秒呼出电话和短信息的限制是什么
  2. 使用Twilio SMS API,我可以在一篇文章中指定多个目的地电话吗
  3. 如何使用twilio API发送批量短信

没有收到来自SMS服务url的响应。由于没有响应,请求处理失败,并且已超过请求的等待时间。服务的连接问题,因此您遇到超时

我在API中使用过此SMS服务在手机上发送消息,以前也遇到过此错误。这是服务器的连接问题。应用程序正在向服务url发送请求,并且它已经等待了一定的时间,当没有收到响应并且超过等待时间时,请求执行由于超时而停止,rails给出了此错误。

相关内容

  • 没有找到相关文章

最新更新