StackExchange / StackExchange/StackExchange.Redis
`ConnectTimeout` exception was throw when use `new ConfigurationOptions`
Open
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.2k
- Forks
- 1.6k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
But if I use ConfigurationOptions.Parse, everything works fine.
StackExchange.Redis.RedisConnectionException: The message timed out in the backlog attempting to send because no connection became available (5000ms) - Last Connection Exception: It was not possible to connect to the redis server(s). ConnectTimeout, command=EVAL, timeout: 5000, inst: 0, qu: 0, qs: 0, aw: False, bw: CheckingForTimeout, rs: NotStarted, ws: Idle, in: 0, last-in: 0, cur-in: 0, sync-ops: 0, async-ops: 1, serverEndpoint: localhost:6379, conn-sec: n/a, aoc: 0, mc: 1/1/0, mgr: 10 of 10 available, clientName: Auth.Web, IOCP: (Busy=0,Free=1000,Min=1,Max=1000), WORKER: (Busy=1,Free=32766,Min=2,Max=32767), POOL: (Threads=3,QueuedItems=0,CompletedItems=54,Timers=2), v: 2.7.27.49176 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
public static IServiceCollection AddCaching(this IServiceCollection services, IConfiguration configuration)
{
services.AddStackExchangeRedisCache(options =>
{
var config = configuration.GetRedisConfiguration();
var a = new ConfigurationOptions
{
ClientName = config.ClientName,
DefaultDatabase = config.DefaultDatabase,
EndPoints = new EndPointCollection([.. config.EndPoints.Cast<EndPoint>()])
};
var b = ConfigurationOptions.Parse(a.ToString());
// Timeout when use a;
options.ConfigurationOptions = a;
// Worked when use b;
// options.ConfigurationOptions = b;
});
return services;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the timeout in the AddStackExchangeRedisCache configuration shown, comparing a directly initialized ConfigurationOptions with the result of ConfigurationOptions.Parse(a.ToString()). Inspect the ConfigurationOptions entry points and connection setup involved. Done means the cause is isolated and the two construction paths behave consistently, with a regression test if the relevant test location is identified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, redis
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100