Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

synchronous example redisClusterConnect2 doesn't work with Redis 5.0.3 #102

Open
arzaidi opened this issue Feb 15, 2019 · 3 comments
Open

Comments

@arzaidi
Copy link

arzaidi commented Feb 15, 2019

cc = redisClusterContextInit();
redisClusterSetOptionAddNodes(cc, "127.0.0.1:9001, 127.0.0.1:9002, 127.0.0.1:9003, 127.0.0.1:9004, 127.0.0.1:9005, 127.0.0.1:9006");
redisClusterConnect2(cc);
if(cc == NULL || cc->err)
{
    printf("connect error : %s\n", cc == NULL ? "NULL" : cc->errstr);
    return -1;
}
redisReply *reply = reinterpret_cast<redisReply*> (redisClusterCommand(cc, "hmget %s %s", key, field));

Results in Error:
reply is null[ctx get by node is null]

But if I replace the first three lines with following, then it works fine:

cc = redisClusterConnect("127.0.0.1:9001,127.0.0.1:9002,127.0.0.1:9003,127.0.0.1:9004,127.0.0.1:9005,127.0.0.1:9006",HIRCLUSTER_FLAG_ROUTE_USE_SLOTS);
@thakurajayL
Copy link

I think this client does not support 4.x & 5.x. Since there is basic change in the the way initial negotiation happens with 4.0/5.0 clusters. Can you check wireshark and confirm

@david-freistrom
Copy link

Setup your context to use slots before connect

redisClusterSetOptionRouteUseSlots(cc);

@Drakeeagle
Copy link

Drakeeagle commented Apr 5, 2022

When I use asyn cluster connect api , I have the same issue. following code failed

const char * paddrs = "ip_0:port_0,ip_1:port_1";
redisClusterAsyncConnect(paddrs, HIRCLUSTER_FLAG_NULL);

Setup your context to use slots before connect

redisClusterSetOptionRouteUseSlots(cc);

if you want to use asyn cluster api, you can add redisClusterSetOptionRouteUseSlots(cc) in the below function

//hircluster.c

static redisClusterContext *_redisClusterConnect(redisClusterContext *cc, const char *addrs) {
  ret = redisClusterSetOptionAddNodes(cc, addrs);
  ...
  redisClusterSetOptionRouteUseSlots(cc);
  cluster_update_route(cc);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants