ServiceStack.Redis.RedisResponseException: No more data, sPort: 50563, LastCommand:

1,284 views
Skip to first unread message

Robert Mircea

unread,
Jul 26, 2011, 4:26:19 PM7/26/11
to servic...@googlegroups.com

Hello,

I am receiving quite often  the following exception from ServiceStack.Redis client. For no apparent reason the following stack trace gets logged into my application. It does not matter what operation I am trying to perform with. It looks like a timeout issue with the pooled client, but it's just a guess:

ServiceStack.Redis.RedisResponseException: No more data, sPort: 50563, LastCommand: 
at ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error) in C:\src\ServiceStack.Redis\src\ServiceStack.Redis\RedisNativeClient_Utils.cs:line 148
at ServiceStack.Redis.RedisNativeClient.ExpectSuccess() in C:\src\ServiceStack.Redis\src\ServiceStack.Redis\RedisNativeClient_Utils.cs:line 384
at ServiceStack.Redis.RedisNativeClient.set_Db(Int32 value) in C:\src\ServiceStack.Redis\src\ServiceStack.Redis\RedisNativeClient.cs:line 138
at ServiceStack.Redis.PooledRedisClientManager.GetClient() in C:\src\ServiceStack.Redis\src\ServiceStack.Redis\PooledRedisClientManager.cs:line 143

I am using self compiled client from the latest bits in the repo.

Pawan

unread,
Sep 1, 2011, 10:26:20 PM9/1/11
to ServiceStack .NET Open Source REST Web Services Framework
Were you able to find the root cause?
> C:\src\ServiceStack.Redis\src\ServiceStack.Redis\PooledRedisClientManager.c s:line

Robert Mircea

unread,
Sep 2, 2011, 4:29:05 AM9/2/11
to servic...@googlegroups.com
Not really... I managed to work around the problem by wrapping the calls with a retry mechanism.

example call:
RetryLogic.RetryForExceptionType(() => cache.DoOperationWithCache, typeof(RedisResponseException), 3, 10);



public class RetryLogic
    {
        public static void RetryForExceptionType(Action action, Type retryOnExceptionType, int numRetries, int retryTimeout)
        {
            if (action == null)
                throw new ArgumentNullException("action");
            if (retryOnExceptionType == null)
                throw new ArgumentNullException("retryOnExceptionType");
            while (true)
            {
                try
                {
                    action();
                    return;
                }
                catch (Exception e)
                {
                    if (--numRetries <= 0 || !retryOnExceptionType.IsAssignableFrom(e.GetType()))
                        throw;
                    if (retryTimeout > 0)
                        System.Threading.Thread.Sleep(retryTimeout);
                }
            }
        } 
    }

Lawrence Botley

unread,
Oct 14, 2014, 6:34:08 AM10/14/14
to servic...@googlegroups.com
A little simpler approach to your retry policy

        public static T Get(string key, int retry = 2)
        {
            try
            {
                using (var redisManager = pooledRedisClientManager)
                using (var redis = redisManager.GetClient())
                {
                    var redisCache = redis.As<T>();
                    var value = redisCache.GetValue(key);
                    return value;
                }
            }
            catch (Exception)
            {
                return --retry == 0 ? default(T) : Get(key, retry);
Reply all
Reply to author
Forward
0 new messages