DEV Community

Joseph King
Joseph King

Posted on

Connect Heroku Redis V6 to .Net Core Heroku App hosted through Docker

I have a staging .Net Core app hosted on Heroku via Docker which uses the Heroku Redis addon as a cache. Heroku recently upgrade all mini plans to version 6 and I understand version 6 requires a TLS connection... sorry if I'm getting this wrong.

In any case, I can't start the app due to the following error from StackExchange.Redis:

Timeout performing SUBSCRIBE (5000ms), inst: 4, qu: 1, qs: 0, aw: False, bw: SpinningDown, serverEndpoint: [amazon ecs endpoint here], mc: 1/1/0, mgr: 10 of 10 available, clientName: 319aa5ff-317f-42e6-9a2e-d0c8e0be9020(SE.Redis-v2.6.66.47313), IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=0,Free=32767,Min=8,Max=32767), POOL: (Threads=6,QueuedItems=0,CompletedItems=302), v: (Please take a look at this article for some common client-side issues that can cause timeouts:
Enter fullscreen mode Exit fullscreen mode

I've tried validating the server certificate with the following:

private static ConfigurationOptions GetHerokuRedisConfigurationOptions(string host, int port, string password)

    var config = new ConfigurationOptions
        ConnectRetry = 3,
        AbortOnConnectFail = false,
        Ssl = true,
        Password = password,
        EndPoints = { { host, port } }

    config.CertificateValidation += ValidateServerCertificate;

    return config;

private static bool ValidateServerCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors sslPolicyErrors)
    if (sslPolicyErrors == SslPolicyErrors.None)
        return true;

    Console.WriteLine("Certificate error: {0}", sslPolicyErrors);

    return false;
Enter fullscreen mode Exit fullscreen mode

This produces the following error:

Certificate error: RemoteCertificateNameMismatch, RemoteCertificateChainErrors

How can I configure the TLS connection in StackExchange.Redis in order to connect to the Heroku Redis Data addon?

Thank you!

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.