Cannot Get Jedis Connection; Could Not Get a Resource from the Pool

Jedis, Cannot get jedis connection: cannot get resource from pool

I moved from redis.template to plain jedis.
Added below configuration(can be added in redis template too) for pool and don't see any exception now:

jedisPoolConfig.setMaxIdle(30);
jedisPoolConfig.setMinIdle(10);

for redis template:

jedisConnectionFactory.getPoolConfig().setMaxIdle(30);
jedisConnectionFactory.getPoolConfig().setMinIdle(10);

Same above config can be added in redis template too.

Cannot get Jedis connection, nested exception: Could not get a resource from the pool

Your port numbers are misconfigured between properties and the self-configured connection factory.

I would recommend sticking with one or the other Spring Boot's RedisAutoconfiguration which pulls in JedisConnectionConfiguration will automatically create a ConnectionFactory for you based of the properties.

https://github.com/spring-projects/spring-boot/blob/8f4bf233b4895a4fade5aff41e0a309f90ba3193/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/JedisConnectionConfiguration.java

Driven from the spring.redis properties.

JedisConnectionException: Could not get a resource from the pool

Not sure what's the overload for your Factory but you're definitely missing the TLS flag.

See this: https://github.com/xetorthio/jedis/blob/master/src/test/java/redis/clients/jedis/tests/SSLJedisTest.java#L55

6380/TCP is TLS enabled in Azure Redis Cache. You can enable 6379/TCP from the Azure Portal for plain text connections or you can do the right thing.

Check out the official quickstart for Jedis with Azure Redis Cache (note the useSsl flag) - https://docs.microsoft.com/en-us/azure/redis-cache/cache-java-get-started

JedisShardInfo shardInfo = new JedisShardInfo("
<name>.redis.cache.windows.net",
6380,
useSsl);

shardInfo.setPassword("<key>"); /* Use your access key. */
Jedis jedis = new Jedis(shardInfo);

jedis.set("foo", "bar");
String value = jedis.get("foo");

nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

I've posted answer here: Could not connect to Redis at 10.XX.XX.28:6379: Unknown error - while accessing from Spring Batch or windows machine.

The solutions works fine for me. It's just config changes nothing else.



Related Topics



Leave a reply



Submit