liubiao4123 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 0 forks source link

Zero length respose #51

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have an ASP.NET MVC application hosted in Windows Azure. The data access 
layer for this application uses the ServiceStack Redis implementation.

Each MVC controller has an instance of a DataService object (data access 
layer). The data service defines methods like CreateUser, GetUsers, GetRoles, 
etc.. Each of these methods calls either GetClient() or GetReadOnlyClient(), 
for example:

public long CountUsers()
{
    var client = _clientManager.GetReadOnlyClient();
    return client.Sets["user:id"].Count;
}

Now the problem is that I always get this "Zero length respose" exception after 
a few clicks. The exception is always thrown for the INFO command that is sent 
directly after opening the socket connection.

Here's an example of a stack trace:

[RedisResponseException: Zero length respose, sPort: 52682, LastCommand: ]
   ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error) +308
   ServiceStack.Redis.RedisNativeClient.ReadData() +137
   ServiceStack.Redis.RedisNativeClient.SendExpectData(Byte[][] cmdWithBinaryArgs) +245
   ServiceStack.Redis.RedisNativeClient.SendExpectString(Byte[][] cmdWithBinaryArgs) +59
   ServiceStack.Redis.RedisNativeClient.get_Info() +150
   ServiceStack.Redis.RedisNativeClient.get_ServerVersion() +49
   ServiceStack.Redis.RedisNativeClient.Connect() +1057
   ServiceStack.Redis.RedisNativeClient.AssertConnectedSocket() +311
   ServiceStack.Redis.RedisNativeClient.SendCommand(Byte[][] cmdWithBinaryArgs) +66
   ServiceStack.Redis.RedisNativeClient.SendExpectData(Byte[][] cmdWithBinaryArgs) +51
   ServiceStack.Redis.RedisNativeClient.GetBytes(String key) +240
   ServiceStack.Redis.RedisNativeClient.Get(String key) +50
   ServiceStack.Redis.RedisClient.GetValue(String key) +59
   ServiceStack.Redis.RedisClient.Get(String key) +96
   Azure.Webshop.UserHelper.GetUserByAuthToken(String token) in C:\Projects\Azure\CloudShop\DataService\CloudShopDataService.User.cs:174
   Azure.Webshop.RequiresAuthenticationAttribute.OnActionExecuting(ActionExecutingContext filterContext) in C:\Projects\Azure\CloudShop\Backend\ActionFilters\RequiresAuthenticationAttribute.cs:36
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +116
...

Any idea why this exception is always thrown after a few clicks?

Original issue reported on code.google.com by daniel.k...@googlemail.com on 22 Nov 2010 at 12:13

GoogleCodeExporter commented 8 years ago
Another point to mention is, that the exception is only thrown within the 
OnActionExecuting method of an action filter.

Original comment by daniel.k...@googlemail.com on 22 Nov 2010 at 9:09

GoogleCodeExporter commented 8 years ago
I need to recall my last comment. Right now the exception was thrown within an 
action method.

Original comment by daniel.k...@googlemail.com on 22 Nov 2010 at 12:26

GoogleCodeExporter commented 8 years ago
Googled to this post. I have met the same problem, it happens once a day or two:

RedisResponseException 
Zero length respose, sPort: 1686, LastCommand:  

Stack Trace:
ServiceStack.Redis.RedisNativeClient.CreateResponseError(String error)
ServiceStack.Redis.RedisNativeClient.ReadData()
ServiceStack.Redis.RedisNativeClient.SendExpectData(Byte[][] cmdWithBinaryArgs)
ServiceStack.Redis.RedisNativeClient.SendExpectDouble(Byte[][] 
cmdWithBinaryArgs)
ServiceStack.Redis.RedisNativeClient.ZIncrBy(String setId, Double incrBy, 
Byte[] value)

Original comment by liyong2...@gmail.com on 14 Feb 2011 at 6:32

GoogleCodeExporter commented 8 years ago
One more point to mention:

I use pooled client manager and native client, opened 100(read) + 100(write) 
connections to a single redis server. The server is a basic CcentOS 5.5 64bit 
box with 16G memory, which is not busy or out of memory.

Original comment by liyong2...@gmail.com on 14 Feb 2011 at 6:36

GoogleCodeExporter commented 8 years ago
I have this ploblem

Original comment by yan00...@gmail.com on 27 Apr 2013 at 9:38

GoogleCodeExporter commented 8 years ago
Same here! And it began with my implementation of Semaphores

Original comment by nickolas...@gmail.com on 18 Dec 2013 at 8:30

GoogleCodeExporter commented 8 years ago
I have the same issue, and from the exception details it looks there is 
something to do with the user session.

It happens to me if I just keep reload a page couple of times, for my site 
every page will require to check user auth so it apply to the request filter, 
however sometime when keep getting user sessions it just hangs, or zero length 
respose will return, really annoying. --- is there any lock statement when 
getting user session?

I googled it that one guy said his problem related to different version of 
redis server, I am use windows server with redis 2.6.12, will servicestack 
support this version?

Original comment by allenk...@gmail.com on 17 Mar 2014 at 2:26

GoogleCodeExporter commented 8 years ago
BTW, here is my stacktrace

     Error Code
        RedisException
    Message
        Unable to Connect: sPort: 3193
    Stack Trace
        at ServiceStack.Redis.RedisNativeClient.CreateConnectionError() at ServiceStack.Redis.RedisNativeClient.SendExpectData(Byte[][] cmdWithBinaryArgs) at ServiceStack.Redis.RedisNativeClient.GetBytes(String key) at ServiceStack.Redis.RedisNativeClient.Get(String key) at ServiceStack.Redis.RedisClient.GetValue(String key) at ServiceStack.Redis.RedisClient.Get[T](String key) at ServiceStack.ServiceInterface.ServiceExtensions.GetSession(IHttpRequest httpReq, Boolean reload) at ServiceStack.ServiceInterface.AuthenticateAttribute.Execute(IHttpRequest req, IHttpResponse res, Object requestDto) at ServiceStack.ServiceInterface.RequestFilterAttribute.RequestFilter(IHttpRequest req, IHttpResponse res, Object requestDto) at ServiceStack.WebHost.Endpoints.EndpointHost.ApplyRequestFilters(IHttpRequest httpReq, IHttpResponse httpRes, Object requestDto) at ServiceStack.WebHost.Endpoints.RestHandler.ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, String operationName)

Original comment by allenk...@gmail.com on 17 Mar 2014 at 2:31