ServiceStack 无法设置与 Redis 的会话

ServiceStack Cannot Set Session with Redis

我正在使用 AuthFeature 来验证我的用户。我在写 Redis 时遇到问题。以前有人经历过吗?

使用由 Choco

安装的 ServiceStack 4.0.40Redis-64 v2.8.19
// Register the caching
container.Register<IRedisClientsManager>(c => new RedisManagerPool(ConfigUtils.GetAppSetting("RedisHost"))); // Host: 127.0.0.1
container.Register<ICacheClient>(c => c.Resolve<IRedisClientsManager>().GetCacheClient());

回复:

{
"userId": null,
"sessionId": null,
"userName": null,
"displayName": null,
"referrerUrl": null,
"responseStatus": {
"errorCode": "RedisResponseException",
"message": "wrong number of arguments for 'set' command, sPort: 56089, LastCommand: SET urn:iauthsession:405vC9TzVCgNuqZxBTwF {\"__type\":\"Subscryb.Auth.SubscrybUserSession, Subscryb\",\"a...",
"stackTrace": "[Authenticate: 5/6/15 6:55:25 PM]:\ [REQUEST: {userName:testuser,password:passwd}]\ ServiceStack.Redis.RedisResponseException: wrong number of arguments for 'set' command, sPort: 56089, LastCommand: SET urn:iauthsession:405vC9TzVCgNuqZxBTwF {\"__type\":\"Subscryb.Auth.SubscrybUserSession, Subscryb\",\"a...\ \ at ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error)\ \ at ServiceStack.Redis.RedisNativeClient.ExpectSuccess()\ \ at ServiceStack.Redis.RedisNativeClient.SendExpectSuccess(Byte[][] cmdWithBinaryArgs)\ \ at ServiceStack.Redis.RedisNativeClient.Set(String key, Byte[] value, Int32 expirySeconds, Int64 expiryMs)\ \ at ServiceStack.Redis.RedisClient.<>c__DisplayClass37`1.<Set>b__34(RedisClient r)\ \ at ServiceStack.Redis.RedisClient.Exec(Action`1 action)\ \ at ServiceStack.Redis.RedisClient.Set[T](String key, T value, TimeSpan expiresIn)\ \ at ServiceStack.Redis.RedisClientManagerCacheClient.Set[T](String key, T value, TimeSpan expiresIn)\ \ at ServiceStack.ServiceExtensions.CacheSet[T](ICacheClient cache, String key, T value, Nullable`1 expiresIn)\ \ at ServiceStack.ServiceStackHost.OnSaveSession(IRequest httpReq, IAuthSession session, Nullable`1 expiresIn)\ \ at ServiceStack.ServiceExtensions.SaveSession(IRequest httpReq, IAuthSession session, Nullable`1 expiresIn)\ \ at ServiceStack.ServiceExtensions.SaveSession(IServiceBase service, IAuthSession session, Nullable`1 expiresIn)\ \ at ServiceStack.Auth.CredentialsAuthProvider.OnAuthenticated(IServiceBase authService, IAuthSession session, IAuthTokens tokens, Dictionary`2 authInfo)\ \ at ServiceStack.Auth.CredentialsAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, String userName, String password, String referrerUrl)\ \ at ServiceStack.Auth.CredentialsAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, Authenticate request)\ \ at ServiceStack.Auth.AuthenticateService.Authenticate(Authenticate request, String provider, IAuthSession session, IAuthProvider oAuthConfig)\ \ at ServiceStack.Auth.AuthenticateService.Post(Authenticate request)\ \ at lambda_method(Closure , Object , Object )\ \ at ServiceStack.Host.ServiceRunner`1.Execute(IRequest request, Object instance, TRequest requestDto)",
"errors": [ ]
},
"meta": null
}

看来我安装了旧版本的Redis 2.4.6,而且那个服务还是运行。通过卸载它,并安装Redis 2.8.19,问题得到解决。