sewenew / redis-plus-plus

Redis client written in C++
Apache License 2.0
1.65k stars 351 forks source link

Failed to insert data into Redis Cluster #221

Closed fang-da-mao closed 3 years ago

fang-da-mao commented 3 years ago

Hi @sewenew ,

I wanted to insert data into a redis cluster which contains three master nodes: port 6380, 6381, 6382.

I connected to certain node just as instructed: sw::redis::RedisCluster redis_cluster("tcp://hostname:6380"); (p.s. in reality, the hostname is my virtual machine's name)

Then I tried: redis_cluster.set("30", "value");

The error is: terminate called after throwing an instance of 'sw::redis::Error' what(): Failed to send command with key: 30 Abort

I also tried another way to connect to the cluster:

sw::redis::ConnectionOptions connection_options; connection_options.host = "hostname";
connection_options.port = 6380;

sw::redis::RedisCluster redis_cluster(connection_options);

But it tells me: 'connection_options' does not name a type connection_options.host = "hostname"; (p.s. in reality, the hostname is my virtual machine's name.)

Could you please help me by taking a look at this issue?

Thanks :)

fang-da-mao commented 3 years ago

Here is more information about the my redis server conf:

port 6380 cluster-enabled yes cluster-config-file nodes.conf cluster-node-timeout 5000 appendonly yes protected-mode no

For other master nodes config file, only the port number is different.

sewenew commented 3 years ago

Can you show me complete code that can reproduce the problem? Especially the code that failed to compile, i.e. 'connection_options' does not name a type. It seems that you didn't install redis-plus-plus correctly. Also please check if you installed more than one hiredis version. In this case, you'll get wired problems.

Regards

sewenew commented 3 years ago

@fang-da-mao Since there's no update from you, I'll close this issue. If you still have problem with it, feel free to reopen it.

Regards