2

我正在尝试学习如何在 ServiceStack 中使用 Redis 进行 UserAuth 持久性。

我的 Global.asax.cs 中有以下代码:

public class HelloAppHost : AppHostBase
{
    public HelloAppHost() : base("Hello Web Services", typeof(HelloService).Assembly) {}

    public override void Configure(Funq.Container container)
    {
        container.Register<ICacheClient>(new MemoryCacheClient());

        Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
            new CredentialsAuthProvider()
        }));
        container.Register(c => new PooledRedisClientManager(
            "127.0.0.1:6379"
        ));
        container.Register<IUserAuthRepository>(
            c => new RedisAuthRepository(c.Resolve<PooledRedisClientManager>()));
    }
}

我在 TCP/6379(来自 Deb7 包)上本地公开了 Redis 的默认安装/配置。

当我调用身份验证服务时,我收到以下错误:

Response Status

Error Code RedisResponseException
MessageZero length respose, sPort: 65470, LastCommand: 
Stack Trace[Auth: 07/06/2013 17:29:08]: [REQUEST: {UserName:test,Password:test}]
ServiceStack.Redis.RedisResponseException: Zero length respose, sPort: 65470, LastCommand: at 
ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error) at 
ServiceStack.Redis.RedisNativeClient.ParseSingleLine(String r) at 
ServiceStack.Redis.RedisNativeClient.ReadData() at 
ServiceStack.Redis.RedisNativeClient.SendExpectData(Byte[][] cmdWithBinaryArgs) at 
ServiceStack.Redis.RedisNativeClient.HGet(String hashId, Byte[] key) at 
ServiceStack.Redis.RedisClient.GetValueFromHash(String hashId, String key) at 
ServiceStack.ServiceInterface.Auth.RedisClientManagerFacade.RedisClientFacade.GetValueFromHash(String hashId, String key) at 
ServiceStack.ServiceInterface.Auth.RedisAuthRepository.GetUserAuthByUserName(IRedisClientFacade redis, String userNameOrEmail) at 
ServiceStack.ServiceInterface.Auth.RedisAuthRepository.GetUserAuthByUserName(String userNameOrEmail) at 
ServiceStack.ServiceInterface.Auth.RedisAuthRepository.TryAuthenticate(String userName, String password, UserAuth& userAuth) at 
ServiceStack.ServiceInterface.Auth.CredentialsAuthProvider.TryAuthenticate(IServiceBase authService, String userName, String password) at 
ServiceStack.ServiceInterface.Auth.CredentialsAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, String userName, String password, String referrerUrl) at 
ServiceStack.ServiceInterface.Auth.CredentialsAuthProvider.Authenticate(IServiceBase authService, IAuthSession session, Auth request) at 
ServiceStack.ServiceInterface.Auth.AuthService.Authenticate(Auth request, String provider, IAuthSession session, IAuthProvider oAuthConfig) at 
ServiceStack.ServiceInterface.Auth.AuthService.Post(Auth request) at 
ServiceStack.ServiceInterface.Auth.AuthService.Get(Auth request) at 
lambda_method(Closure , Object , Object ) at ServiceStack.ServiceHost.ServiceRunner`1.Execute(IRequestContext requestContext, Object instance, TRequest request)

是什么导致了这个错误?

我怀疑它可能是以下之一:

- 我需要以某种方式设置 Redis 吗?- 我的 Global.asax.cs 中是否有错误?-还有什么遗漏吗?-我完全走错了吗?!

谢谢!

4

1 回答 1

1

如果其他人有这个问题,看起来这是由于客户端和服务器之间的版本不匹配(debian 7 稳定包来自旧的 2.4.x 分支)。我从 2.6.13 源代码构建了服务器,一切似乎都很好。

于 2013-06-08T10:20:11.027 回答