vipshop / hiredis-vip

Support redis cluster. Maintained and used at vipshop.
BSD 3-Clause "New" or "Revised" License
322 stars 173 forks source link

How to set timeout on a redis cluster client #128

Open yyhclimacool opened 4 years ago

yyhclimacool commented 4 years ago

hiredis-vip : master date : 2019-11-25 hiredis version in hircluster.h : 1.0.0

In my code, I got a redisClusterContext, I called struct timeval tv = { _timeout_ms / 1000, (_timeout_ms % 1000) * 1000}; _context = redisClusterConnectWithTimeout(_host.c_str(), tv, HIRCLUSTER_FLAG_NULL); if (redisClusterSetOptionTimeout(_context,tv) != REDIS_OK) { /* log on error */ }

Why it won't work, if I set _timeout_ms=10 , my redis command timer still get a number bigger than 10, say 29 maybe...

sdouek commented 4 years ago

Also happen to me: Doesn't timeout properly when server is unreachable. when you will fix it ?

wangfuqiang commented 2 years ago

Also happen to me: Doesn't timeout properly when server is unreachable. when you will fix it ?

wangfuqiang commented 2 years ago

Also happen to me: Doesn't timeout properly when server is unreachable. when you will fix it ?

how do you solve this pro?

wangfuqiang commented 2 years ago

hiredis-vip : master date : 2019-11-25 hiredis version in hircluster.h : 1.0.0

In my code, I got a redisClusterContext, I called struct timeval tv = { _timeout_ms / 1000, (_timeout_ms % 1000) * 1000}; _context = redisClusterConnectWithTimeout(_host.c_str(), tv, HIRCLUSTER_FLAG_NULL); if (redisClusterSetOptionTimeout(_context,tv) != REDIS_OK) { /* log on error */ }

Why it won't work, if I set _timeout_ms=10 , my redis command timer still get a number bigger than 10, say 29 maybe...

how do you solve this pro?