Quantcast
Channel: Active questions tagged redis+ruby-on-rails - Stack Overflow
Viewing all articles
Browse latest Browse all 873

Can't connect to clustered Azure Redis Cache with redis-rb gem and public access

$
0
0

We've provisioned an Azure Redis Cache server using the Premium tier. The server is clustered, with 2 shards, and the server is configured to allow public access over the public internet through a firewall--allow-listing a set of known IPs.

Deploys of our Rails application two any of these known IPs fail with the error:

Redis::CannotConnectError: Redis client could not connect to any cluster nodes

Here is our Rails config:

# application.rb if Rails.env.test?      config.cache_store = :redis_cache_store, {        url: config.nines[:redis_url],        expires_in: 90.minutes,        namespace: ENV['TEST_ENV_NUMBER'],      }    else      config.cache_store = :redis_store, {        namespace:ENV['TEST_ENV_NUMBER'],        cluster: [ Rails.application.config.nines[:redis_url] ],        replica: true, # allow reads from replicas        compress: true,        compress_threshold: 1024,        expires_in: 90.minutes      }    end

The config.nines[:redis_url] is set like this: rediss://:<pw>@<cache-name>.redis.cache.windows.net:6380/0

Then, we initialize the Redis connection in code like this:

if Rails.env.test?  ::Redis.new :url => redis_url, :db => ENV['REDIS_DB']else  ::Redis.new(cluster: [ "#{redis_url}" ], db: ENV['REDIS_DB'])end

We're using the redis-rb gem and redis-rails gem.

If anyone can point out what we're doing wrong, please do share!


Viewing all articles
Browse latest Browse all 873

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>