1

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

3
  • have you tried updating the Redis to v5 or v6? Commented Apr 16, 2021 at 4:04
  • Can you please try redis = Redis.new(ssl_params: {verify_mode: OpenSSL::SSL::VERIFY_NONE}) and then redis.set Commented Apr 16, 2021 at 5:10
  • Any updates on this ToddT? Commented Jun 28, 2022 at 16:56

1 Answer 1

1

So Its an ssl verify cert error. I got the same error and find a solution via github

I tried to send verify_mode into ssl_paramss of redis instance like below

redis = Redis.new(ssl_params: {verify_mode: OpenSSL::SSL::VERIFY_NONE})

You can find out https://github.com/redis/redis-rb/issues/940

also there is another flag ssl: true or false you can use that too

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.