Connection string not working, works in other places

We’re setting up our first Redis server (version 7.0.1). The credentials given to me are working using the Redli utility, and also in c# connecting to via the StackExchange.Redis library. But not via the SS library.

Error is “RedisResponseException: WRONGPASS invalid username-password pair or user is disabled.” If I use the exact string produced by the variable SvrWithCreds below in redli, I can connect.

Sample code to reproduce:

string usr = "xxxxxx";
string pwd = "yyyyyyy";
string svr = "redis01.zzzzz.com";
int port = 6379;

// ----------------- StackExchange.Redis ---------------------------
var opt = new StackExchange.Redis.ConfigurationOptions()
{
    User = usr,
    Password = pwd,
    EndPoints =
                { { svr, port } }
};

var redis = StackExchange.Redis.ConnectionMultiplexer.Connect(opt);

StackExchange.Redis.IDatabase db = redis.GetDatabase();
string value = db.StringGet("x");
Console.WriteLine(value);

// ----------------- ServiceStack.Redis ---------------------------
string SvrWithCreds = $"redis://{usr}:{pwd}@{svr}:{port}";
Console.WriteLine(SvrWithCreds);

var pool = new ServiceStack.Redis.RedisManagerPool(SvrWithCreds);
var client = pool.GetClient();

Redis doesn’t have connection strings, they’re only a feature of client libraries which all implement them differently, you can find info on ServiceStack.Redis connection strings here:
https://docs.servicestack.net/redis/client-managers

Thank you, I feel like I’m following the last example on that page exactly but am still unable to connect.

Redis by default doesn’t have users, so your {usr} is just a client identifier, if you’re using Redis ACLs you’ll need to specify it on the query string:

$"redis-service:6379?username={usr}&password={pwd}"

If your password uses special chars you’ll need to escape it, e.g:

$"redis-service:6379?username={usr}&password={pwd.UrlEncode()}"

But Redis ACL support is a relatively new feature which requires the latest v6.1 on NuGet.

Thank you, that fixed my issue.

A note for your endless TODO list: add the Username parameter to the Managing Connections webpage you referred to above.

Yep already updated it.