连接超时。有关配置,请告诉我们

时间:2016-12-08 13:55:05

标签: ruby-on-rails redis sidekiq

我们正在使用heroku redistogo lite计划

````
# = Limits ===================================================================
maxmemory 52428800
maxmemory-policy volatile-lru
maxmemory-samples 3

maxclients 128
timeout 150

`````
proc文件中的

```
worker: bundle exec sidekiq -c 3 -v -q default -q medium

```

我的配置:

```
require 'sidekiq'
require 'sidekiq/web'
require 'log4r'

Sidekiq.configure_server do |config|
Sidekiq::Logging.logger = Log4r::Logger.new 'sidekiq'
Sidekiq::Logging.logger.level = Log4r::INFO
Sidekiq::Logging.logger.level = Logger::WARN
Rails.logger = Sidekiq::Logging.logger
  # config.redis = { db: 1 }
  config.redis = { url: ENV['REDISTOGO_URL'] }
  config.server_middleware do |chain|
    chain.add Sidekiq::Status::ServerMiddleware, expiration: 90.minutes # default
  end
end

Sidekiq.configure_client do |config|
  config.redis = { size: 1, url: ENV['REDISTOGO_URL'] }
  config.client_middleware do |chain|
    chain.add Sidekiq::Status::ClientMiddleware, expiration: 90.minutes # default
  end
end

# ActiveRecord::Base.logger = Sidekiq::Logging.logger
Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_token]
Sidekiq::Web.set :sessions, Rails.application.config.session_options

`````

错误:

`````
    Error message
NameError: Connection timed out

Stack trace (show Rails)
…by/2.2.0/gems/redis-3.3.2/lib/redis/connection/
ruby.rb: 105:in `write_nonblock'
…by/2.2.0/gems/redis-3.3.2/lib/redis/connection/
ruby.rb: 105:in `_write_to_socket'
…by/2.2.0/gems/redis-3.3.2/lib/redis/connection/
ruby.rb: 131:in `block in write'
…by/2.2.0/gems/redis-3.3.2/lib/redis/connection/
ruby.rb: 130:in `loop'
…by/2.2.0/gems/redis-3.3.2/lib/redis/connection/
ruby.rb: 130:in `write'
…by/2.2.0/gems/redis-3.3.2/lib/redis/connection/
ruby.rb: 374:in `write'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 271:in `block in write'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 250:in `io'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 269:in `write'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 228:in `block (3 levels) in process'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 222:in `each'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 222:in `block (2 levels) in process'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 367:in `ensure_connected'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 221:in `block in process'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 306:in `logging'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 220:in `process'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 187:in `call_pipelined'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 157:in `block in call_pipeline'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 293:in `with_reconnect'
…bundle/ruby/2.2.0/gems/redis-3.3.2/lib/redis/
client.rb: 155:in `call_pipeline'
…vendor/bundle/ruby/2.2.0/gems/redis-3.3.2/lib/
redis.rb:2304:in `block in multi'
…vendor/bundle/ruby/2.2.0/gems/redis-3.3.2/lib/
redis.rb:  58:in `block in synchronize'
       /app/vendor/ruby-2.2.4/lib/ruby/2.2.0/
monitor.rb: 211:in `mon_synchronize'
…vendor/bundle/ruby/2.2.0/gems/redis-3.3.2/lib/
redis.rb:  58:in `synchronize'
…vendor/bundle/ruby/2.2.0/gems/redis-3.3.2/lib/
redis.rb:2296:in `multi'
…ems/sidekiq-status-0.6.0/lib/sidekiq-status/
storage.rb:  16:in `block in store_for_id'
…ems/sidekiq-status-0.6.0/lib/sidekiq-status/
storage.rb: 102:in `block in redis_connection'
….2.0/gems/connection_pool-2.2.1/lib/
connection_pool.rb:  64:in `block (2 levels) in with'
….2.0/gems/connection_pool-2.2.1/lib/
connection_pool.rb:  63:in `handle_interrupt'
….2.0/gems/connection_pool-2.2.1/lib/
connection_pool.rb:  63:in `block in with'
….2.0/gems/connection_pool-2.2.1/lib/
connection_pool.rb:  60:in `handle_interrupt'
….2.0/gems/connection_pool-2.2.1/lib/
connection_pool.rb:  60:in `with'
…ems/sidekiq-status-0.6.0/lib/sidekiq-status/
storage.rb: 101:in `redis_connection'
…ems/sidekiq-status-0.6.0/lib/sidekiq-status/
storage.rb:  15:in `store_for_id'
…q-status-0.6.0/lib/sidekiq-status/
client_middleware.rb:  26:in `call'
…2.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/
chain.rb: 130:in `block in invoke'
…2.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/
chain.rb: 133:in `call'
…2.0/gems/sidekiq-4.1.4/lib/sidekiq/middleware/
chain.rb: 133:in `invoke'
…le/ruby/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq/
client.rb: 206:in `process_single'
…le/ruby/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq/
client.rb:  65:in `push'
…le/ruby/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq/
worker.rb: 116:in `client_push'
…le/ruby/2.2.0/gems/sidekiq-4.1.4/lib/sidekiq/
worker.rb:  60:in `perform_async'
             /app/app/controllers/
batches_controller.rb:  43:in `create_batch'
…0/gems/actionview-4.2.5.1/lib/action_view/
rendering.rb:  30:in `process'
…uby/2.2.0/gems/omniauth-1.3.1/lib/omniauth/
strategy.rb: 186:in `call!'
…uby/2.2.0/gems/omniauth-1.3.1/lib/omniauth/
strategy.rb: 164:in `call'
…ruby/2.2.0/gems/omniauth-1.3.1/lib/omniauth/
builder.rb:  63:in `call'
…/gems/rack-ssl-enforcer-0.2.9/lib/rack/
ssl-enforcer.rb:  52:in `call'
…/gems/rack-ssl-enforcer-0.2.9/lib/rack/
ssl-enforcer.rb:  52:in `call'
…dle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/
manager.rb:  35:in `block in call'
…dle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/
manager.rb:  34:in `catch'
…dle/ruby/2.2.0/gems/warden-1.2.6/lib/warden/
manager.rb:  34:in `call'
…dor/bundle/ruby/2.2.0/gems/rack-1.6.5/lib/rack/
etag.rb:  24:in `call'
…/ruby/2.2.0/gems/rack-1.6.5/lib/rack/
conditionalget.rb:  38:in `call'
…dor/bundle/ruby/2.2.0/gems/rack-1.6.5/lib/rack/
head.rb:  13:in `call'
…/2.2.0/gems/rack-1.6.5/lib/rack/session/abstract/
id.rb: 225:in `context'
…/2.2.0/gems/rack-1.6.5/lib/rack/session/abstract/
id.rb: 220:in `call'
…/ruby/2.2.0/gems/rack-1.6.5/lib/rack/
methodoverride.rb:  22:in `call'
…/bundle/ruby/2.2.0/gems/rack-1.6.5/lib/rack/
runtime.rb:  18:in `call'
…undle/ruby/2.2.0/gems/rack-cors-0.3.0/lib/rack/
cors.rb:  72:in `call'
…lib/phusion_passenger/rack/
thread_handler_extension.rb:  81:in `block in process_request'
…lib/phusion_passenger/rack/
thread_handler_extension.rb: 367:in `maybe_tag_logger'
…lib/phusion_passenger/rack/
thread_handler_extension.rb:  81:in `process_request'
…ib/phusion_passenger/request_handler/
thread_handler.rb: 145:in `accept_and_process_next_request'
…ib/phusion_passenger/request_handler/
thread_handler.rb:  98:in `main_loop'
…c/ruby_supportlib/phusion_passenger/
request_handler.rb: 440:in `block (3 levels) in start_threads'
…r-5.1.0/src/ruby_supportl

请建议我们。

  

Ruby版本:2.2.1 Sidekiq / Pro / Enterprise版本:4.1.4
  如果相关,请包含您的初始化程序和任何错误消息   完全回溯。

1 个答案:

答案 0 :(得分:1)

从您的客户端配置中删除size: 1。如果需要,让Sidekiq创建更多连接。