记录一次redis连接报错:
Caused by: org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 10.55.55.55:6379 at org.springframework.data.redis.connection.lettuce.LettucePoolingConnectionProvider.getConnection(LettucePoolingConnectionProvider.java:109) at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1417) ... 60 common frames omitted Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 10.16.10.82:32405 at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78) at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56) at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:234) at io.lettuce.core.RedisClient.connect(RedisClient.java:207) at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.lambda$getConnection$1(StandaloneConnectionProvider.java:115) at java.util.Optional.orElseGet(Optional.java:267) at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:115) at org.springframework.data.redis.connection.lettuce.LettucePoolingConnectionProvider.lambda$null$0(LettucePoolingConnectionProvider.java:97) at io.lettuce.core.support.ConnectionPoolSupport$RedisPooledObjectFactory.create(ConnectionPoolSupport.java:209) at io.lettuce.core.support.ConnectionPoolSupport$RedisPooledObjectFactory.create(ConnectionPoolSupport.java:199) at org.apache.commons.pool2.basePooledObjectFactory.makeObject(basePooledObjectFactory.java:58) at org.apache.commons.pool2.impl.GenericObjectPool.create(GenericObjectPool.java:889) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:424) at org.apache.commons.pool2.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:349) at io.lettuce.core.support.ConnectionPoolSupport$1.borrowObject(ConnectionPoolSupport.java:122) at io.lettuce.core.support.ConnectionPoolSupport$1.borrowObject(ConnectionPoolSupport.java:117) at org.springframework.data.redis.connection.lettuce.LettucePoolingConnectionProvider.getConnection(LettucePoolingConnectionProvider.java:103) ... 61 common frames omitted
看日志错误信息发现ip 端口等都没有问题,检查redis服务发现也是打开的。
只能再去检查项目配置文件,redis配置如下
spring:
# redis 配置
redis:
# 地址
host: 10.55.55.55
# 端口,默认为6379
port: 6379
# 密码
password:
# 连接超时时间
timeout: 10
lettuce:
pool:
# 连接池中的最小空闲连接
min-idle: 0
# 连接池中的最大空闲连接
max-idle: 5
# 连接池的最大数据库连接数
max-active: 5
# #连接池最大阻塞等待时间(使用负值表示没有限制)
max-wait: -1
发现同事把timeout值设置的过小,timeout:10,应该是还没建立完连接就断开了。所以才会报Could not get a resource from the pool这个错误。
后来把该值修改3000,再次启动,成功!



