2881099 / csredis

.NET Core or .NET Framework 4.0+ client for Redis and Redis Sentinel (2.8) and Cluster. Includes both synchronous and asynchronous clients.
MIT License
2.01k stars 414 forks source link

使用XPending方法报错 #481

Open MornSunWang opened 1 year ago

MornSunWang commented 1 year ago

使用方法setClient.XPending(key, groupName, "-", "+", 10)时, 报 Unexpected response type: MultiBulk (expecting Bulk) 错误

2881099 commented 1 year ago

type key 看看返回内容

MornSunWang commented 1 year ago

key 就是string类型啊,我实际传入的值是“wang”。在redis-cli中,可以通过:xpending wang sale - + 10 返结果。调用 setClient.XPending("wang", "sale", "-", "+", 10)就会报 Unexpected response type: MultiBulk (expecting Bulk) 错误,调用setClient.XPending("wang", "sale"),可以返回总数。我使用的版本号是:3.8.670,我希望能拿到未回复消息的明细

2881099 commented 1 year ago

3.8.670是什么意思,提供一个重现的console app上传一下

MornSunWang commented 1 year ago
    static void Main(string[] args)
    {
        string conn = "127.0.0.1:6379,password=wwl_shian_2021";
        CSRedisClient redisClient = new CSRedisClient(conn); //CSRedisCore NuGet包版本号:3.8.670
        RedisHelper.Initialization(redisClient);

        redisClient.XAdd("keyName", ("msg", "test1"));
        redisClient.XGroupCreate("keyName", "group1");
        redisClient.XAdd("keyName", ("msg", "test2"));
        redisClient.XAdd("keyName", ("msg", "test3"));

        redisClient.XReadGroup("group1", "consumer1", 1, 0, ("keyName", ">"));
        var info1= redisClient.XPending("keyName", "group1");  //可以获取信息

        //报错,CSRedis.RedisProtocolException:“Unexpected response type: MultiBulk (expecting Bulk)”
        var info2 = redisClient.XPending("keyName", "group1","-","+",10);  
    }
2881099 commented 1 year ago

哦哦,建议切换到 FreeRedis

https://github.com/2881099/FreeRedis