SeanH
SeanH

Reputation: 584

ServiceStack.Redis timeout on Azure

I'm moving my ServiceStack API from Linux/Mono (On my own hardware) to the Azure App Service, using SS 4.5.2. My Redis cache is 3.2 running on a Linux VM. I am NOT using the Azure Redis service.

I'm seeing this exception being thrown seemingly at random:

RedisException - Exceeded timeout of 00:00:03

The exception seems to be thrown from services using the authenticate attribute, as every stack trace includes "ServiceStack.ServiceExtensions.GetSession" and "ServiceStack.AuthenticateAttribute.Execute". I'm currently only using Redis for session storage, so this bit is no surprise.

I'm registering my ICacheClient as follows, which has been working on my previous Linux/Mono setup in production for some time:

container.Register<IRedisClientsManager>(c =>
    new RedisManagerPool("SomeRedisMachine:6379")); 

container.Register(c => c.Resolve<IRedisClientsManager>().GetCacheClient());

I did see the post on the SS forms: https://forums.servicestack.net/t/redis-exception-exceeded-timeout-of-00-00-03/2301 - However this only seems to apply when using the Azure Redis service, which I am not.

Given this info, there are several questions I will have to find an answer to:

Thanks in advance for any insight!

Update

As per mythz suggestion, I did update to SS v4.5.4. The exception is still thrown, however with a slightly different message (Exceeded timeout of 00:00:10) consistent with the mentioned updated timeout.

I decided to target an Azure Redis Service (As opposed to a Linux VM). I so far see no errors related to Redis in either ServiceStack 4.5.2 or 4.5.4. Perhaps whatever hosts Microsoft is using for their own Redis service have a better network connection and/or are closer to the cluster handling app services.

Upvotes: 3

Views: 891

Answers (1)

mythz
mythz

Reputation: 143399

The Redis TimeoutException is a symptom of an unhealthy environment which is preventing the Redis Client from establishing a TCP connection. This could be as a result of your redis-server instance or Network being overloaded or unreliable.

You can increase the Timeout to give the Redis Client more time to make a connection with:

RedisConfig.DefaultRetryTimeout = 10 * 1000;

Which is also the new default timeout from ServiceStack.Redis v4.5.4+.

Upvotes: 2

Related Questions