-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Context:
Starting from redis 7.x. two new properties cluster-preferred-endpoint-type and cluster-announce-hostname properties have been added. When cluster-preferred-endpoint-type is set to hostname, Moved and Ask responses contain the hostnames.
When cluster-announce-hostname is set, cluster nodes outputs the hostname along with the Ip. https://redis.io/docs/latest/commands/cluster-nodes/
cluster nodes output:
07c37dfeb235213a872192d90877d0cd55635b91 127.0.0.1:30004@31004,hostname4 slave e7d1eecce10fd6bb5eb35b9f99a514335d9ba9ca 0 1426238317239 4 connected
Problem:
When the nodes in the cluster have announced hostnames. hiredis-cluster should parse the hostnames instead of IPs from cluster nodes output and connect to the nodes via hostnames.
By default, hiredis-cluster runs cluster nodes and uses the IPs to make connections to the individual nodes. This integration will not work when the nodes are behind a proxy/NAT gateway, thus, we are expecting that when cluster-preferred-endpoint-type is set to hostname, on moving and connecting to a different node hiredis-cluster will use hostname instead of IP.
Solution:
Suggesting hiredis-cluster to make connections via hostnames if available and default to IPs if not present