question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Redis Cluster: Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

See original GitHub issue

Hi,

I have created redis cluster with default scripts from latest stable redis 3.0.0 release and cluster is created successfully. $redis-3.0.0/utils/create-cluster# ./create-cluster start Starting 30001(M) Starting 30002(M) Starting 30003(M) Starting 30004(S) Starting 30005(S) Starting 30006(S) $redis-3.0.0/utils/create-cluster# ./create-cluster create

And I’m implemented a small java main method class to test the redis cluster using Jedis 7.0 API, Snippet:

public class RedisCTest {

public static void main(String[] args) {

    Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
    //Jedis Cluster will attempt to discover cluster nodes automatically
    jedisClusterNodes.add(new HostAndPort("host", 30001));
    jedisClusterNodes.add(new HostAndPort("host", 30002));
    jedisClusterNodes.add(new HostAndPort("host", 30003));
    JedisCluster jc = new JedisCluster(jedisClusterNodes);
    System.out.println("Cluster Size...." + jc.getClusterNodes().size());
    jc.set("foo1", "bar1");
    jc.set("foo2", "bar2");
    jc.set("foo3", "bar3");
    jc.set("foo4", "bar4");

}

} First time it is working fine and keys are stored into redis , when I run this program multiple time’s, I’m getting below exception:

Console Output:

Cluster Size…9 Exception in thread “main” redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool.java:50) at redis.clients.jedis.JedisPool.getResource(JedisPool.java:86) at redis.clients.jedis.JedisClusterConnectionHandler.renewSlotCache(JedisClusterConnectionHandler.java:72) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:75) at redis.clients.jedis.JedisClusterCommand.runWithRetries(JedisClusterCommand.java:67) at redis.clients.jedis.JedisClusterCommand.run(JedisClusterCommand.java:29) at redis.clients.jedis.JedisCluster.set(JedisCluster.java:70) at redisclustertest.RedisCTest.main(RedisCTest.java:35) Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.ConnectException: Connection refused: connect at redis.clients.jedis.Connection.connect(Connection.java:154) at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:83) at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1643) at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:85) at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:819) at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:819) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:429) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:360) at redis.clients.util.Pool.getResource(Pool.java:48) … 7 more Caused by: java.net.ConnectException: Connection refused: connect at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method) at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at redis.clients.jedis.Connection.connect(Connection.java:148) … 14 more Java Result: 1

Thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:18

github_iconTop GitHub Comments

1reaction
Pratap6commented, Apr 13, 2015

@marcosnils : Thanks for your support, we greatly appreciate your help!

we have successfully done remote connectivity from client to Redis Cluster. by replacing Bind IP(127.0.0.1) in redis.conf file with machine IP.

@HeartSaVioR : Thanks for your support, we greatly appreciate your help!

0reactions
sazzad16commented, Nov 19, 2017

The issuer considered this fixed.

Pratap6

we have successfully done remote connectivity from client to Redis Cluster. by replacing Bind IP(127.0.0.1) in redis.conf file with machine IP.

marcosnils

Can you please close the issue if you consider it fixed?

Pratap6

Ok sure

Removing tag.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Could not get a resource from the pool ... - Stack Overflow
Still i'm getting the error "Could not get a resource from the pool". The stacktrace is given below. redis.clients.jedis.exceptions.JedisConnectionException: ...
Read more >
Could not get a resource from the pool ... - GitHub
JedisConnectionException : Could not get a resource from the pool at redis.clients.util.Pool.getResource(Pool.java:53) at redis.clients.jedis ...
Read more >
Could not get a resource from the pool ...
I'm running multiple worker threads(around 10) to access the data from the redis Q. For the i'm using infinte timeout for Jedis Client....
Read more >
What Should I Do If an Error Is Returned When I Use the Jedis ...
redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool. If this error message is displayed, ...
Read more >
Summary of common exceptions in Redis | by July - Medium
Explain one by one. Error overview. redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool; redis.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found