連線redis時遇到Caused by: io.netty.channel.ConnectTimeoutException: connection timed out: /問題
阿新 • • 發佈:2020-08-21
連線不到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 to192.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 to192.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中可以檢視到快取資料【不知道為什麼開始沒查到,又刷了幾次頁面查到了】