I’m trying to connect to Redis Instance with Redis OM. But I’m getting Below error.
The timeout was reached before the message could be written to the output buffer, and it was not sent, command=UNKNOWN, timeout: 5000, inst: 0, qu: 0, qs: 10, aw: False, bw: CheckingForTimeout, rs: ReadAsync, ws: Idle, in: 0, in-pipe: 0, out-pipe: 0, serverEndpoint: my-dev-redisServer.redis.server.windows.net:6380, mc: 1/1/0, mgr: 10 of 10 available, clientName: <My machiene name>, IOCP: (Busy=0,Free=1000,Min=12,Max=1000), WORKER: (Busy=0,Free=32767,Min=12,Max=32767), POOL: (Threads=6,QueuedItems=0,CompletedItems=65), v: 2.5.61.22961 (Please take a look at this article for some common client-side issues that can cause timeouts: https://stackexchange.github.io/StackExchange.Redis/Timeouts)
Failed on FT.CREATE ClassRoom -idx ON Hash PREFIX 1 ClassRoom SCHEMA Id TAG SEPARATOR | Persons TAG SEPARATOR |
I tried setting min thread count to resolve the issue, but it is still throwing same error.
[Document(StorageType = StorageType.Json, Prefixes = new[] { "ClassRoom" })]
public sealed class ClassRoom
{
[RedisIdField][Indexed] public string Id { get; set; }
[Indexed(JsonPath = "$.Id")] public List<Person> Persons { get; set; }
}
public class Person
{
[Indexed] public int Id { get; set; }
public String Name{ get; set; }
}
Connection string format : redis://:password@host:portNumber
Below are example models similar to mine. I’m using HostedService approach to create Indices as explained here https://redis.io/docs/stack/get-started/tutorials/stack-dotnet/
Thanks for your help!
2
Answers
On looking at the error message closely I found that threads are exhausting as one they are not able to connect to the redis server, which could happen if redis server access is blocked by VPN, incorrect connection string.
In my case connection string was correct as I was able to connect redis with redis insight using same connection string.
VPN was not blocking my access either as redis insight was also behind the VPN and was able to connect to redis without any problems.
I checked connection object which was created by
new RedisConnectionProvider(builder.Configuration["REDIS_CONNECTION_STRING"])
and noticed that the connection object is pointing to incorrect port with ssl disabled. And this was the reason why I was not able to connect to redis.
To solve this I used an overload of
RedisConnectionProvider
class constructor which is not listed in documentation and it solved the problem for me.TLDR: used overload of
RedisConnectionProvider
class constructor to solve the problem.First, increase your timeout to 15 sec in the connection string.
Increase the number of threads (Program.cs or Startup.cs):