Redis Redis 连接异常,用的是阿里云云数据库 Redis 版

bighuzi · July 11, 2018 · Last by bighuzi replied at July 11, 2018 · 8006 hits

在 config/initalizers/redis.rb 中链接方式

if Rails.env.production?
    $redis = Redis.new(:host =>' XXXX', :password => "XXXX", :port => 6379, db: 2)
else
    $redis = Redis.new(:host => 'localhost', :port => 6379, db: 2)
end

出现异常 Redis::CommandError (ERR invalid password):

actioncable 中的 cable.yml 中 redis 配置

development:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
  channel_prefix: friend_production

test:
  adapter: async

production:
  adapter: redis
  url: <%= ENV.fetch("REDIS_URL") { "redis://XXXX:6379" } %>
  password: 'XXXXXX'
  channel_prefix: friend_production

actioncable 能链接上 redis

问题已解决了。。主要是不能用上面那种链接方式 得用:https://github.com/redis/redis-rb url 方式链接

bighuzi closed this topic. 11 Jul 16:35
You need to Sign in before reply, if you don't have an account, please Sign up first.