Skip to content

Change Redis cluster port mapping to work on mac#1061

Open
kowser-orkes wants to merge 2 commits intomainfrom
bugfix/jedis-port-conflict
Open

Change Redis cluster port mapping to work on mac#1061
kowser-orkes wants to merge 2 commits intomainfrom
bugfix/jedis-port-conflict

Conversation

@kowser-orkes
Copy link
Copy Markdown
Contributor

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • WHOSUSING.md
  • Other (please describe):

NOTE: Please remember to run ./gradlew spotlessApply to fix any format violations.

Changes in this PR

JedisClusterCommandsBatchTest was failing with JedisClusterOperationException: Cluster retry deadline exceeded / SocketTimeoutException: Read timed out because of a Redis Cluster port-mapping mismatch.

The test maps container ports 7000–7005 to host ports 17000–17005 to avoid a conflict with macOS Control Center, which permanently occupies port 7000 on macOS (it registers as afs3-fileserver). However, Redis Cluster nodes advertise their own address to clients via the cluster topology (MOVED redirects), and the container's nodes announce themselves on their internal ports (7000–7005). When Jedis followed a redirect to 127.0.0.1:7000, that port was not open on the host, causing every connection attempt to time out.

Fix: pass a HostAndPortMapper in DefaultJedisClientConfig when constructing JedisCluster. The mapper intercepts every address returned by the cluster topology and shifts ports 7000–7005 → 17000–17005, so Jedis always connects through the exposed host ports.

Issue #

Alternatives considered

Map container ports 7000→7000 (original setup): Fails on macOS because Control Center permanently occupies port 7000 (afs3-fileserver). This is a macOS system process that cannot be stopped, so the original mapping is not viable on developer machines running macOS.

Use Testcontainers' dynamic port assignment: Would avoid fixed-port conflicts entirely, but requires the Redis cluster image to support runtime cluster-announce-port configuration (injected as env vars at startup). The current orkesio/redis-cluster image does not expose that knob, so this would need an image change.

@kowser-orkes kowser-orkes force-pushed the bugfix/jedis-port-conflict branch from 23aacea to 0acb831 Compare May 5, 2026 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant