Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not get a resource from the pool #7

Closed
mlc0202 opened this issue Jul 20, 2015 · 4 comments
Closed

Could not get a resource from the pool #7

mlc0202 opened this issue Jul 20, 2015 · 4 comments

Comments

@mlc0202
Copy link

mlc0202 commented Jul 20, 2015

When i use redis-cache in my project ,it throws exception,as you see,"Could not get a resource from the pool".
this is more infomation

Cause: redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool] with root cause

java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(DualStackPlainSocketImpl.java)
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:144)
at redis.clients.jedis.BinaryClient.connect(BinaryClient.java:71)
at redis.clients.jedis.BinaryJedis.connect(BinaryJedis.java:1783)
at redis.clients.jedis.JedisFactory.makeObject(JedisFactory.java:65)
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:40)
at redis.clients.jedis.JedisPool.getResource(JedisPool.java:84)

@mlc0202
Copy link
Author

mlc0202 commented Jul 20, 2015

I used redis 3.0.3 with centos 6.2

@live106
Copy link

live106 commented Oct 29, 2015

Have you config the redis.properties file?
Note that the default host is "localhost" and port 6379.

@songjiesdnu
Copy link
Contributor

I had the same problem as you.Finally i debug the source code, and found that there is a bug.
File:RedisConfigurationBuilder.java(line:100)
The orginal code is: jedisConfig.setHost("localhost");
I modified this code to: jedisConfig.setHost(config.getProperty("redis.ip"));
And this solved the problem.

songjiesdnu added a commit to songjiesdnu/redis-cache that referenced this issue Dec 27, 2015
solve the problem:Could not get a resource from the pool mybatis#7
@emacarron
Copy link
Member

Hi all.

The line "jedisConfig.setHost("localhost");" was indeed wrong but made no difference because the value was lately overwritten by the "host" property from the config file. Moreover, if there was no "host" property "localhost" will be set by default in RedisConfig.

So if you are getting a connection proproblem I would 1st check your host and port are right in your propierties file as @live106 pointed.

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

No branches or pull requests

4 participants