org.redisson.client.WriteRedisConnectionException: Unable to send command!
利用redisson作为分布式锁。常时间未操作,报出如下错误:org.redisson.client.WriteRedisConnectionException: Unable to send command!
具体内容如下:
Caused by: org.redisson.client.WriteRedisConnectionException: Unable to send command! Node source: NodeSource [*********************] after 3 retry attempts
at org.redisson.command.CommandAsyncService.checkWriteFuture(CommandAsyncService.java:837)
at org.redisson.command.CommandAsyncService.access$200(CommandAsyncService.java:92)
at org.redisson.command.CommandAsyncService$11$1.operationComplete(CommandAsyncService.java:794)
at org.redisson.command.CommandAsyncService$11$1.operationComplete(CommandAsyncService.java:791)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:485)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121)
at io.netty.channel.AbstractChannel$AbstractUnsafe.safeSetFailure(AbstractChannel.java:991)
at io.netty.channel.AbstractChannel$AbstractUnsafe.write(AbstractChannel.java:873)
at io.netty.channel.DefaultChannelPipeline$HeadContext.write(DefaultChannelPipeline.java:1365)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:738)
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:730)
at io.netty.channel.AbstractChannelHandlerContext.access$1700(AbstractChannelHandlerContext.java:38)
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:1127)
at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:1174)
at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:1098)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:495)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
... 1 common frames omitted
Caused by: java.nio.channels.ClosedChannelException: null
at io.netty.channel.AbstractChannel$AbstractUnsafe.write(...)(Unknown Source)
当前使用版本为redisson3.9.1
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>3.9.1</version>
</dependency>
查询github源码https://github.com/redisson/redisson,发现解决方案:
The connection not reconnect #1811
这个issue发生提到的错误,问题的出现基本和我遇到的一致,并且在Fixed - connection is not reconnected #1811中解决了,所以…!
问题总结
在redis出问题之后,watchdog发现连接无效之后,然后打印了一个警告日志之后,就没法有自动重连了,导致继续使用该连接的时候出问题,问题解决,ConnectionWatchdog.channelInactive.tryReconnect方法:
最后升级到:redisson-parent-3.11.6 redisson-3.16.1 redisson-3.16.0 redisson-3.15.6 redisson-3.15.5 redisson-3.15.4 redisson-3.15.3 redisson-3.15.2 redisson-3.15.1 redisson-3.15.0 redisson-3.14.1 redisson-3.14.0 redisson-3.13.6 redisson-3.13.5 redisson-3.13.4 redisson-3.13.3 redisson-3.13.2 redisson-3.13.1 redisson-3.13.0 redisson-3.12.5 redisson-3.12.4 redisson-3.12.3 redisson-3.12.2 redisson-3.12.1 redisson-3.12.0 redisson-3.11.6 redisson-3.11.5 redisson-3.11.4 redisson-3.11.3 redisson-3.11.2 redisson-3.11.1 redisson-3.11.0 redisson-3.10.7 redisson-3.10.6 redisson-3.10.5 redisson-3.10.4 redisson-3.10.3 redisson-3.10.2 redisson-3.10.1 redisson-2.15.2 redisson-2.15.1,搞定!!!