I regularly get ServiceStack.Redis: Unable to Connect: sPort: 0 or ServiceStack.Redis: Unable to Connect: sPort: 50071 (or another port number).
This appears to happen when our site is busier. Redis itself appears fine, no real increase in CPU or memory usage.
I'm using connection pooling and have tried changing the timeout values without success.
public sealed class RedisConnection
{
// parameter values are:
// Config.Settings.RedisPoolSize = 10000
// Config.Settings.RedisPoolTimeoutSeconds = 2
// Config.Settings.RemoteCacheServerName = 192.168.10.12
private static readonly PooledRedisClientManager instance
= new PooledRedisClientManager(Config.Settings.RedisPoolSize,
Config.Settings.RedisPoolTimeoutSeconds,
new string[] { Config.Settings.RemoteCacheServerName })
{
ConnectTimeout = 1500
};
static RedisConnection()
{
}
public static PooledRedisClientManager Instance
{
get
{
return instance;
}
}
}
Usage is like this:
public sealed class Caching
{
public static T GetCacheSingle<T>(string key)
{
using (var redisClient = RedisConnection.Instance.GetReadOnlyClient())
{
var value = redisClient.Get<byte[]>(key);
....
}
}
}