splitrb / split

:chart_with_upwards_trend: The Rack Based A/B testing framework
https://rubygems.org/gems/split
MIT License
2.71k stars 368 forks source link

SSL_connect error when opening dashboard or calling ab_test() or ab_finished() since updating our Heroku redis from 5 to 7 #708

Closed chrisatboilerjuice closed 1 year ago

chrisatboilerjuice commented 1 year ago

Hi!

I'm hoping you guys might be able to help us out with this issue.

We have been using Split for a while now and it has been great!

Our dev ops guy has recently updated our Heroku Redis from version 5 to version 7 and everything on Split has stopped working. When I try and access the dashboard or call any of the methods like ab_finished we get this error in our logs: SSL_connect returned=1 errno=0 state=error: certificate verify failed (self-signed certificate in certificate chain)

We had a few other troubles when we updated but have managed to solve them other than getting Split to work again and we really stuck with why it's still not working.

We have done a few changes, like making sure our redis initializer had the verify_mode: OpenSSL::SSL::VERIFY_NONE set we tried altering the split initializer setting the redis part using the ENV['REDIS_URL'] which before we had left out by your documents saying this should be picked out.

If you need any more details to help investigate just let me know and ill do my best to get it.

Thanks, Chris

guillermoAMS commented 1 year ago

Hello there,

Our dev ops guy has recently updated our Heroku Redis from version 5 to version 7 and everything on Split has stopped working

The reason why you experienced the problem above is because Redis version 6 and higher has native TLS support. However Heroku manages SSL differently (https://devcenter.heroku.com/articles/http-routing#routing).

_We have done a few changes, like making sure our redis initializer had the verify_mode: OpenSSL::SSL::VERIFY_NONE set we tried altering the split initializer setting the redis part using the ENV['REDISURL'] which before we had left out by your documents saying this should be picked out.

You can create a Redis initializer file, like the one that is mentioned in the documentation at Heroku (https://devcenter.heroku.com/articles/http-routing#routing):

# config/initializers/redis.rb
$redis = Redis.new(
  url: ENV["REDIS_URL"],
  ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }
)

Then use that Redis instance in your Split initializer file:

# config/initializers/split.rb
Split.configure do |config|
  config.redis = $redis
end

I hope this helped you out, Cheers!

andrehjr commented 1 year ago

Hi @chrisatboilerjuice 🙌

I think @guillermoAMS is right. Heroku has changed and any Redis instance should be configured with ssl_params configured. https://devcenter.heroku.com/articles/connecting-heroku-redis#connecting-in-ruby

You should also be able to configure redis directly by doing:Split.redis = Redis.new(...)

Are you still having trouble?

chrisatboilerjuice commented 1 year ago

Hi @guillermoAMS,

Yes! Adding the ssl_params part along with the Redis URL did the trick.

Thank you so much.

francirp commented 1 year ago

Should we consider updating the Readme to include a comment that you can pass the initialized Redis instance into the config.redis variable? When I read the Readme I assumed you could only pass the actual string URL.

Perhaps like:

config.redis = "redis://custom.redis.url:6380" # can pass initialized Redis instance here (e.g. $redis)