I'm facing an issue while connecting to Redis server via HAProxy using Jedis as a redis client. Everything works fine when Redis server is directly connected to but, the same is not working via HAProxy. Both HAProxy and Redis services are running on their specific ports, HAProxy on port 80 & Redis server on 6379. We are running this setup on EC2 instances and all the necessary ports are open.
HAProxy Configuration is
frontend redis-in
bind *:80
default_backend redis-server
backend redis-server
stats enable
server redis-server1 x.x.x.x:6379 check inter 1000 fall 3 rise 2
server redis-server2 x.x.x.x:6379 check inter 1000 fall 3 rise 2
Jedis Clinet code is:
try {
Jedis jedis = new Jedis(hostname, port);
jedis.set("key", "Redis-Test-Value");
System.out.println("value from redis node is: " + jedis.get("key"));
} catch (Exception e) {
System.out.println("exception is " + e);
}
Exception message that gets thrown is - redis.clients.jedis.exceptions.JedisConnectionException: Unknown reply: H
Can someone point out what am I missing and point to the right direction?