sewenew / redis-plus-plus

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

[QUESTION]How to solve the redis-cluster server replay MOVED redirect address by redis-plus-plus #600

Closed gxp0306 closed 1 month ago

gxp0306 commented 1 month ago

When using Redis Plus plus as a client to connect to the Redis cluster and access Redis, the Redis server replies with an Invalid ASK error message: 1492 1172:: 1: fd2a: 6379, requiring the client to use a redirect address for access. How can Redis Plus Plus retrieve data through the MOVED redirect address of Redis cluster

sewenew commented 1 month ago

Thanks for reporting this!

When parsing the ASK and MOVED error message, redis-plus-plus separates the message with the first whitespace and colon. However, this does not work IPV6, since it has colon in the IP part. I'll fix the problem by finding the colon from reverse order to separate port from the IP part.

B.T.W. Are you sure there're whitespace in the IP part? I don't think it's valid IPV6 format.

Regards

gxp0306 commented 1 month ago

Thank you for your reply! Yeah, there're no whitespace in the IPV6.But if redis-cluster server replay redirect address ip is ipv4,How can use redis-plus-plus to get redis data througth redirect address,wheather redis-plus-plus can get redis data througth redirect address automaticly,applications do not anything.such as MOVED command.

sewenew commented 1 month ago

I fixed the code to make it support IPv6 on dev branch. Could you please test it with the dev branch? I don't have IPv6 env to do the test. Thanks!

But if redis-cluster server replay redirect address ip is ipv4,How can use redis-plus-plus to get redis data througth redirect address,wheather redis-plus-plus can get redis data througth redirect address automaticly

redis-plus-plus handles MOVED and ASK error, and follow the redirection to get the data. The application code doesn't need to handle these errors.

Regards

sewenew commented 1 month ago

I did some tests in IPv4 env, merged the code into master branch, and made a new release.

Regards

fjccc commented 2 weeks ago

Hello, I would like to know the specific version corresponding to this dev branch

fjccc commented 2 weeks ago

Hello, I would like to ask if you can provide the link to the code submission when you solved this problem. We want to see the specific changes made.

sewenew commented 2 weeks ago

Hello, I would like to ask if you can provide the link to the code submission when you solved this problem. We want to see the specific changes made.

You can check this PR