spring-data-redis
spring-data-redis copied to clipboard
RedisClusterConfiguration not support ipv6 clusterNodes
excuse me
i find org.springframework.data.redis.connection.RedisClusterConfiguration not support ipv6 .
for example Configuration yml file:
but get the ipv error such as:
the ipv6 fe80::a00:27ff:fe4b:ee48/6379 split fe80: and a00:27ff:fe4b:ee48/6379
how to solve?
Please use hostnames for the time being.
Please use hostnames for the time being.
thank you for your help ,that's good idea ! I've solved it
@fufk2022 - I'm curious how you arrived at the format for the host(s) and port(s) declared in your YAML configuration file when configuring Redis (cluster) nodes in which to connect, located by IPv6 addresses?
For instance, in your application.yaml (?) configuration file shown above, for the spring.redis.cluster.nodes property, you declared:
fe80::a00:27ff:fe4b:ee48/6379,...
NOTE: Just singling out 1 Redis server node here...
Where host is fe80::a00:27ff:fe4b:ee48 (IPv6 address of host running Redis server) and port is 6379 (default Redis port) separated by the /. How did you come up with the host and port separator using /?
I did not find any specification of the host & port format separated by a / when declared in configuration in any of our documentation; not in Spring Data Redis docs here or here, nor in Spring Boot's documentation here or here.
Though the spring.redis.cluster.nodes property is specific to Spring Data Redis, Spring Boot also declares (search for "spring.data.redis") the spring.data.redis.cluster.nodes property as a comma-separated list of "host:port" pairs as well, that is, where the host and port are separated by :.
Anyway, after digging through the SD Redis source code, starting with the RedisClusterConfiguration class you referenced above (and specifically, this source), after reading the value of the spring.redis.cluster.nodes property (here), the class calls the appendClusterNodes(..) method, which delegates to the RedisNode class (Javadoc), and specifically, the RedisNode.fromString(hostPortString) method.
As you can see in the Javadoc of the RedisNode.fromString(..) method, it should handle both IPv4 and IPv6 addresses with port specifications.
However, in your case, the format as declared in your YAML configuration file would be:
spring:
redis:
cluster
nodes: [fe80::a00:27ff:fe4b:ee48]:6379, [fe80::a00:27ff:fe4b:ee48]:6378
Can you please confirm that this would also work in your case, in addition to using hostnames as suggested by @mp911de?
@fufk2022 - Following up to my earlier post above, to verify my findings, I wrote an additional unit test verifying that using an IPv6 address and port combinations for Redis cluster configuration via the spring.redis.cluster.nodes property in YAML, or any other configuration source for that matter, works as expected.
As you can see in the IPv6 address and port declarations at the beginning of the test class, the pattern is exactly as I described in my previous post, essentially:
[IPv6-address]:port
I will wait for a short period of time before closing this ticket, in case you have any additional feedback on this matter. But, I would have to say this works as expected.
@fufk2022 - 1 final thing worthing noting here, I thought it would be pertinent to also document the format of an IP address when declared in Spring Data Redis properties like this.
This is part of a larger effort that I am currently undertaking to revise and edit the Spring Data Redis reference documentation, in general. So, I deliberately make a special mention about the RedisConfiguration interface, where the implementations are commonly used to (in)directly customize the RedisConnection, such as by declaring or specifying a comma-delimited list of host/port pairs (for example, by using the spring.redis.cluster.nodes property with "clustered" Redis connections).
Anyway, you can track my progress and changes in the topic branch (issue/2484) for #2484.
Feedback welcomed.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.