以下是“获取”方法:
def self.get(url, params={})
url = API_DOMAIN + url + '.json'
uri = URI.parse(url)
uri.query = URI.encode_www_form(params)
http = Net::HTTP.new(uri.host,uri.port)
path = uri.path
path += "?#{uri.query}" if uri.query
request = Net::HTTP::Get.new(path)
response = http.request(request)
return response
end
奇怪的是,这个错误似乎只发生在最后 2 天。有没有人最近遇到过类似的问题?
A EOFError occurred in home#index:
end of file reached
/usr/share/ruby/1.9/net/protocol.rb:141:in `read_nonblock'
-------------------------------
Backtrace:
-------------------------------
/usr/share/ruby/1.9/net/protocol.rb:141:in `read_nonblock'
/usr/share/ruby/1.9/net/protocol.rb:141:in `rbuf_fill'
/usr/share/ruby/1.9/net/protocol.rb:122:in `readuntil'
/usr/share/ruby/1.9/net/protocol.rb:132:in `readline'
/usr/share/ruby/1.9/net/http.rb:2562:in `read_status_line'
/usr/share/ruby/1.9/net/http.rb:2551:in `read_new'
/usr/share/ruby/1.9/net/http.rb:1319:in `block in transport_request'
/usr/share/ruby/1.9/net/http.rb:1316:in `catch'
/usr/share/ruby/1.9/net/http.rb:1316:in `transport_request'
/usr/share/ruby/1.9/net/http.rb:1293:in `request'
vendor/cache/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
/usr/share/ruby/1.9/net/http.rb:1286:in `block in request'
/usr/share/ruby/1.9/net/http.rb:745:in `start'
/usr/share/ruby/1.9/net/http.rb:1284:in `request'
vendor/cache/gems/rest-client-1.6.7/lib/restclient/net_http_ext.rb:51:in `request'
vendor/cache/bundler/gems/api_client-0f800898fc1b/lib/api_client/api.rb:15:in `get'
vendor/cache/bundler/gems/api_client-0f800898fc1b/lib/api_client/show.rb:32:in `recommended_each_channel'
app/controllers/application_controller.rb:238:in `set_public_home_page_params'
app/controllers/home_controller.rb:15:in `index'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal/implicit_render.rb:4:in `send_action'
vendor/cache/gems/actionpack-3.2.3/lib/abstract_controller/base.rb:167:in `process_action'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal/rendering.rb:10:in `process_action'
vendor/cache/gems/actionpack-3.2.3/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:458:in `_run__2733272990067146596__process_action__983397386520577802__callbacks'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/cache/gems/actionpack-3.2.3/lib/abstract_controller/callbacks.rb:17:in `process_action'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal/rescue.rb:29:in `process_action'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `block in instrument'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `instrument'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
vendor/cache/gems/activerecord-3.2.3/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
vendor/cache/gems/actionpack-3.2.3/lib/abstract_controller/base.rb:121:in `process'
vendor/cache/gems/actionpack-3.2.3/lib/abstract_controller/rendering.rb:45:in `process'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal.rb:203:in `dispatch'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
vendor/cache/gems/actionpack-3.2.3/lib/action_controller/metal.rb:246:in `block in action'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:73:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:36:in `call'
vendor/cache/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
vendor/cache/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
vendor/cache/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:600:in `call'
vendor/cache/gems/omniauth-1.1.3/lib/omniauth/strategy.rb:177:in `call!'
vendor/cache/gems/omniauth-1.1.3/lib/omniauth/strategy.rb:157:in `call'
vendor/cache/gems/omniauth-1.1.3/lib/omniauth/strategy.rb:177:in `call!'
vendor/cache/gems/omniauth-1.1.3/lib/omniauth/strategy.rb:157:in `call'
vendor/cache/gems/omniauth-1.1.3/lib/omniauth/strategy.rb:177:in `call!'
vendor/cache/gems/omniauth-1.1.3/lib/omniauth/strategy.rb:157:in `call'
vendor/cache/gems/omniauth-1.1.3/lib/omniauth/builder.rb:48:in `call'
vendor/cache/bundler/gems/exception_notification-192a49a02d63/lib/exception_notifier.rb:19:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
vendor/cache/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
vendor/cache/gems/rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/head.rb:14:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/flash.rb:242:in `call'
vendor/cache/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
vendor/cache/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/cookies.rb:338:in `call'
vendor/cache/gems/activerecord-3.2.3/lib/active_record/query_cache.rb:64:in `call'
vendor/cache/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `_run__3080212943900396864__call__954872682800432584__callbacks'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
vendor/cache/gems/railties-3.2.3/lib/rails/rack/logger.rb:26:in `call_app'
vendor/cache/gems/railties-3.2.3/lib/rails/rack/logger.rb:16:in `call'
vendor/cache/gems/actionpack-3.2.3/lib/action_dispatch/middleware/request_id.rb:22:in `call'
vendor/cache/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
vendor/cache/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
vendor/cache/gems/activesupport-3.2.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
vendor/cache/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
vendor/cache/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
vendor/cache/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
vendor/cache/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
vendor/cache/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
vendor/cache/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
vendor/cache/gems/railties-3.2.3/lib/rails/engine.rb:479:in `call'
vendor/cache/gems/railties-3.2.3/lib/rails/application.rb:220:in `call'
vendor/cache/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/rack/request_handler.rb:96:in `process_request'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_request_handler.rb:516:in `accept_and_process_next_request'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_request_handler.rb:274:in `main_loop'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/rack/application_spawner.rb:206:in `start_request_handler'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/rack/application_spawner.rb:171:in `block in handle_spawn_application'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/utils.rb:470:in `safe_fork'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/rack/application_spawner.rb:166:in `handle_spawn_application'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_server.rb:180:in `start'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/rack/application_spawner.rb:129:in `start'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/spawn_manager_orig.rb:253:in `block (2 levels) in spawn_rack_application'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/spawn_manager_orig.rb:246:in `block in spawn_rack_application'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_server_collection.rb:82:in `block in synchronize'
<internal:prelude>:10:in `synchronize'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/spawn_manager_orig.rb:244:in `spawn_rack_application'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/spawn_manager_orig.rb:137:in `spawn_application'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/spawn_manager.rb:16:in `spawn_application_with_env'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/spawn_manager_orig.rb:275:in `handle_spawn_application'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_server.rb:357:in `server_main_loop'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/lib/phusion_passenger/abstract_server.rb:206:in `start_synchronously'
/var/lib/passenger-standalone/3.0.17-x86_64-ruby1.9.3-linux-gcc4.6.2-1002/support/helper-scripts/passenger-spawn-server:99:in `<main>'