Could not get a resource from the pool(SocketTimeoutException:)

1,489 views
Skip to first unread message

vignesh dharma

unread,
Oct 24, 2012, 3:07:24 AM10/24/12
to jedis...@googlegroups.com

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.

Jedis jedis = pool.getResource();
jedis
.getClient().setTimeoutInfinite();  

Still i'm getting the error "Could not get a resource from the pool". The stacktrace is given below.

redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool
at redis
.clients.util.Pool.getResource(Pool.java:22)
at
Workers.Worker1.met1(Worker1.java:124)
at
Workers.Worker1.work(Worker1.java:108)
at org
.gearman.impl.worker.WorkerConnectionController$3.run(Unknown Source)
at java
.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java
.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java
.lang.Thread.run(Unknown Source)  

Caused by: redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketTimeoutException: connect timed out
at redis
.clients.jedis.Connection.connect(Connection.java:124)
at redis
.clients.jedis.BinaryClient.connect(BinaryClient.java:54)
at redis
.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1657)
at redis
.clients.jedis.JedisPool$JedisFactory.makeObject(JedisPool.java:63)
at org
.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1188)
at redis
.clients.util.Pool.getResource(Pool.java:20)
... 6 more  

Caused by: java.net.SocketTimeoutException: connect timed out
at java
.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java
.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java
.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java
.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java
.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java
.net.PlainSocketImpl.connect(Unknown Source)
at java
.net.SocksSocketImpl.connect(Unknown Source)
at java
.net.Socket.connect(Unknown Source)
at redis
.clients.jedis.Connection.connect(Connection.java:119)
... 11 more

Jonathan Leibiusky

unread,
Oct 24, 2012, 8:09:09 AM10/24/12
to jedis...@googlegroups.com
Are you returning the resource after using it? Are you sure the information provided to the pool actually work? Try to use the same information with regular Jedis to make sure it is correct.

vignesh dharma

unread,
Oct 25, 2012, 2:13:10 AM10/25/12
to jedis...@googlegroups.com
Ya i'm returning the resource after using it. I didnt get your question "Are you sure the information provided to the pool actually work?". This the code i'm using all 10 worker threads.

JedisPool pool = new JedisPool(new JedisPoolConfig(), RedisServerURL); 
Jedis jedis = pool.getResource();
jedis.getClient().setTimeoutInfinite();

redisQMesssage = jedis.rpop("QName");
//other Q manipulation code 

//At the end
pool.returnResource(jedis); 
pool.destroy();

vignesh dharma

unread,
Oct 26, 2012, 6:46:56 AM10/26/12
to jedis...@googlegroups.com
In my Java App I'm using Jedis2.0.0.jar file and redis server version is 2.4.13. Is it making the problem?


On Wednesday, October 24, 2012 5:39:17 PM UTC+5:30, Jonathan L. wrote:
Reply all
Reply to author
Forward
0 new messages