首页 新闻 会员 周边 捐助

C/C++ 调用libhiredisAPI接口报错(error) MOVED 12345 ip:port, 怎么解决?

0
悬赏园豆:10 [待解决问题]

这是集群中的一个节点, 连接之后直接调用发送命令, 然后就报错
MOVED 12539 192.168.6.251:19002

char *hostname = "192.168.6.251";
int port = 19003;

struct timeval timeout = { 1, 500000 }; // 1.5 seconds
//c = redisConnect(hostname, port);
redisContext *con = redisConnectWithTimeout(hostname, port, timeout);
if (con == NULL || con->err) {
    if (con) {
        printf("Connection error: %s\n", con->errstr);
        redisFree(con);
    } else {
        printf("Connection error: can't allocate redis context\n");
    }
    return -1;
}
redisReply *reply = (redisReply *)redisCommand(con,"set key hello");
printf("Set return: %s\n", reply->str);
freeReplyObject(reply);
freeRedis(con);
灰狼哥的主页 灰狼哥 | 初学一级 | 园豆:194
提问于:2019-05-13 19:43
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册