1

The following code in C# works for connecting to Heroku Redis without encryption (free tiers):

var redisUrlString = Environment.GetEnvironmentVariable("REDIS_URL");
var redisUri = new Uri(redisUrlString);
var userInfo = redisUri.UserInfo.Split(':');
var redisConnString = $"{redisUri.Host}:{redisUri.Port},password={userInfo[1]}";
var redisConn = StackExchange.Redis.ConnectionMultiplexer.Connect(redisConnString);
var redisDb = redisConn.GetDatabase();
redisDb.StringGet("test");

When Heroku Redis is upgraded to any commercial tier, encryption is required and the code above fails with timeout, while with the following error message appears in the Heroku logs:

app[redis-asymmetrical]: Error accepting a client connection: error:1408F10B:SSL routines:ssl3_get_record:wrong version number

When the code is modified by adding ssl=true to the connection string:

var redisUrlString = Environment.GetEnvironmentVariable("REDIS_URL");
var redisUri = new Uri(redisUrlString);
var userInfo = redisUri.UserInfo.Split(':');
var redisConnString = $"{redisUri.Host}:{redisUri.Port},password={userInfo[1]},ssl=true";
var redisConn = StackExchange.Redis.ConnectionMultiplexer.Connect(redisConnString);
var redisDb = redisConn.GetDatabase();
redisDb.StringGet("test");

It still doesn't doesn't work and the error is now different:

app[redis-asymmetrical]: Error accepting a client connection: (null)

What am I missing?

adamsfamily
  • 1,746
  • 19
  • 37

0 Answers0