Rails:4.2.5 Redis:3.2.2 Errno::ECONNREFUSED Redis::CannotConnectErrorを倒す
問題
トリガーするとError connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
でアプリケーションが落ちてしまう。
/path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:332:in `rescue in establish_connection': Error connecting to Redis on localhost:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError)
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:318:in `establish_connection'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:94:in `block in connect'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:280:in `with_reconnect'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:93:in `connect'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:351:in `ensure_connected'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:208:in `block in process'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:293:in `logging'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:207:in `process'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis/client.rb:113:in `call'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:2085:in `block in publish'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:57:in `block in synchronize'
from /Users/hirokishirai/.rbenv/versions/2.3.0/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:57:in `synchronize'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/redis-3.2.2/lib/redis.rb:2084:in `publish'
from /path_to_app_dir/vendor/bundle/ruby/2.3.0/gems/websocket-rails-0.7.0/lib/websocket_rails/synchronization.rb:63:in `block in publish'
2つの解決策
どちらも動作確認済みです。
moaaさんのfixesをそのまま使っちゃうか、とりあえずredisを3.2.0にダウングレードしてwebsocket-railのマスターにfixesがマージされるのを待つかです。どちらでも良いと思います。
方法1 moaa/websocket-rails
のsync_fixes
ブランチを使う
Gemfileを次のように書き換える
- gem 'websocket-rails'
+ gem 'websocket-rails', github: 'moaa/websocket-rails', branch: 'sync_fixes'
方法2 gem 'redis'
のバージョンを3.2.0
にダウングレードする
Gemfileを次のように書き換える
- gem 'redis'
+ gem 'redis', '3.2.0'
redisをupdate(Gemfile.lockでバージョンがロックされているのでbundle installは通らないはず)
bundle update redis
Source↓
Redis error when sending two different messages · Issue #313 · websocket-rails/websocket-rails
Author And Source
この問題について(Rails:4.2.5 Redis:3.2.2 Errno::ECONNREFUSED Redis::CannotConnectErrorを倒す), 我々は、より多くの情報をここで見つけました https://qiita.com/hirokishirai/items/bdba2308c33eb2486681著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .