ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

连接redis时遇到Caused by: io.netty.channel.ConnectTimeoutException: connection timed out: /问题

2020-08-21 18:34:03  阅读:58  来源: 互联网

标签:netty java Caused redis lettuce io org


连接不到redis错误:

Caused by: io.netty.channel.ConnectTimeoutException: connection timed out: /192.168.211.133:6379

 

  • 这个问题有很大的可能是Linux的防火墙未关闭,请求无法到达redis客户端。
  • 我使用的Centos7 ,查看防火墙和6的命令应该是不同的,之前在这个地方都跌倒过了

 

2020-08-21 17:43:42.091  INFO 25692 --- [nio-8004-exec-4] io.lettuce.core.KqueueProvider           : Starting without optional kqueue library
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 192.168.211.133:6379
    at org.springframework.data.redis.connection.lettuce.LettucePoolingConnectionProvider.getConnection(LettucePoolingConnectionProvider.java:109)
    at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:1198)
    at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:1179)
   。
。  此
。  处
。  省
。  去
。  多
。  行
   。
at java.lang.Thread.run(Thread.java:748) Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 192.168.211.133:6379 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) ... 69 more Caused by: io.netty.channel.ConnectTimeoutException: connection timed out: /192.168.211.133:6379 at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:261) at io.netty.util.concurrent.PromiseTask.runTask(PromiseTask.java:98) at io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:150) at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:510) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:518) at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ... 1 more

 

 

  • 外部访问redis的前提是把redis配置文件中的 protected-mode yes,改为 protected-mode no 这样redis才允许外部访问
  • 查看Linux防火墙状态命令:systemctl status firewalld.service

systemctl status firewalld.service
  • running 是防火墙正在运行

 

 

 

 原来是防火墙没有关闭

  • 关闭防火强命令:systemctl stop firewalld.service
  • 出现 dead 说明防火强关闭
systemctl stop firewalld.service

 

 

 

 

成功了

 

在redis中可以查看到缓存数据【不知道为什么开始没查到,又刷了几次页面查到了】

 

标签:netty,java,Caused,redis,lettuce,io,org
来源: https://www.cnblogs.com/ooo888ooo/p/13542747.html

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有