When I make my first call to sidekiq on Heroku, the following error is thrown:
Redis::CannotConnectError: Error connecting to Redis on 127.0.0.1:6372
Which of course is not the IP of my Heroku:Redis. That URL is defined in my ENV vars as:
rediss://:[email protected]:port
Interestingly in a Heroku console I do this:
redis = Redis.new
which correctly returns:
=> #<Redis client v4.2.5 for redis://blah-blah-blah.compute-1.amazonaws.com:port/0>
But then when I do:
redis.set("hey", "you")
I get:
OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain))
I have the following in my sidekiq.rb
require 'sidekiq'
Sidekiq.configure_client do |config|
Sidekiq::Status.configure_client_middleware config, expiration: 30.minutes
if Rails.env.production?
url = URI.parse(ENV["REDIS_URL"])
url.scheme = "rediss"
url.port = Integer(url.port) + 1
config.redis = {
url: url.to_s,
network_timeout: 5,
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
}
end
end
Sidekiq.configure_server do |config|
Sidekiq::Status.configure_server_middleware config, expiration: 30.minutes
Sidekiq::Status.configure_client_middleware config, expiration: 30.minutes
if Rails.env.production?
url = URI.parse(ENV["REDIS_URL"])
url.scheme = "rediss"
url.port = Integer(url.port) + 1
config.redis = {
url: url.to_s,
network_timeout: 5,
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
}
end
end
Here is my redis.rb
require 'uri'
url = URI.parse(ENV["REDIS_URL"])
url.scheme = "rediss"
url.port = Integer(url.port) + 1
$redis = Redis.new(url: url, driver: :ruby, ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE })
Procfile
release: bin/rails db:migrate
web: bin/start-stunnel bin/rails server -p ${PORT:-5000} -e $RAILS_ENV
worker: bin/start-stunnel bundle exec sidekiq
and I'm running redis - 4.2.5 sidekiq - 6.2.0 ruby - 2.6.5
redis = Redis.new(ssl_params: {verify_mode: OpenSSL::SSL::VERIFY_NONE})and thenredis.set