Open arwace opened 1 year ago
Hi! Subscribe is not yet supported by hiredis-cluster. We want to fix it in the future. See #27.
One possibility to get the published data is to use hiredis
directly. You can get the hiredis context from hiredis-cluster like this:
/* Get a node. */
nodeIterator iter;
initNodeIterator(&iter, cc);
redisClusterNode *node = nodeNext(&iter);
/* Another way is
* node = redisClusterGetNodeByKey(cc, "some key");
*/
/* Get the hiredis context, connect if needed */
redisContext *c = ctx_get_by_node(cc, node);
/* Use hiredis functions with context c,
* for example loop to get all pubsub messages */
redisReply *reply = redisCommand(c, "SUBSCRIBE foo");
freeReplyObject(reply);
while (redisGetReply(c, (void *)&reply) == REDIS_OK) {
// consume message
freeReplyObject(reply);
}
Hello?
I'm having trouble subscribing. When I use redisClusterCommand, I get an error saying that I don't have a key and shouldn't do it, When using redisClusterCommandToNode, the SUBSCRIBE command works fine, but I can't get the publish data with redisClusterGetReply. What should I do in this case?