pingpong2020
pingpong2020

Reputation: 147

Azure cache for Redis - Getting Socket failure exception while connection on 6380 port

Trying to connect to the Azure cache for redis instance using SSL port 6380 but no luck. If I change the port to non-ssl 6379, I can able to connect to it, no issue.

How to overcome the below issue?

Note: Ensure SSL

var configurationOptions = new ConfigurationOptions
{
    EndPoints = { "***.redis.cache.windows.net:6380" },
    Password = "*****=",
    Ssl = true,
    ConnectTimeout = 5000,
    SyncTimeout = 5000,
    IncludeDetailInExceptions = true,
    AbortOnConnectFail = false, 
};


// Use a custom IConnectionMultiplexer
var connectionMultiplexer = ConnectionMultiplexer.Connect(configurationOptions);

// Add Redis to the services container with a custom IConnectionMultiplexer
builder.Services.AddSingleton<IConnectionMultiplexer>(connectionMultiplexer);
builder.Services.AddStackExchangeRedisCache(options =>
{
    options.ConfigurationOptions = configurationOptions; // Use the custom ConfigurationOptions
});

var database = connectionMultiplexer?.GetDatabase(); // throws below exception
var value = await database!.StringGetAsync("key");

Exception: StackExchange.Redis.RedisConnectionException: 'The message timed out in the backlog attempting to send because no connection became available (1000ms) - Last Connection Exception: SocketFailure on my-redis.redis.cache.windows.net:6380/Interactive, Initializing/NotStarted, last: NONE, origin: ConnectedAsync, outstanding: 0, last-read: 0s ago, last-write: 0s ago, keep-alive: 60s, state: Connecting, mgr: 10 of 10 available, last-heartbeat: never, global: 0s ago, v: 2.8.16.12844, command=GET, timeout: 1000, inst: 0, qu: 0, qs: 0, aw: False, bw: CheckingForTimeout, rs: NotStarted, ws: Initializing, in: 0, last-in: 0, cur-in: 0, sync-ops: 0, async-ops: 2, serverEndpoint: my-redis.redis.cache.windows.net:6380, conn-sec: n/a, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: THIRU(SE.Redis-v2.8.16.12844), IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=1,Free=32766,Min=12,Max=32767), POOL: (Threads=7,QueuedItems=0,CompletedItems=89,Timers=2), v: 2.8.16.12844 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)'

Upvotes: 0

Views: 118

Answers (1)

pingpong2020
pingpong2020

Reputation: 147

This issue get resolved magically once after I get installed redis-cli on my window pc. Anyone knows the technical reason behind this?

p.s: Since Redis is not officially supported on Windows, first need to enable WSL2 (Windows Subsystem for Linux), followed by redis-cli installation

Upvotes: 0

Related Questions