远程主机强行关闭现有连接

时间:2019-07-12 05:21:35

标签: java

在我的项目开始时,我使用redis来保持会话,发生这种情况: 1分钟内几乎是一个循环。

这个基于SpringBoot2.0.1和redis vsersion的项目在docker上是4.0。

===2019-07-12 11:11:02.468 INFO  io.lettuce.core.protocol.ConnectionWatchdog Line:106 - Reconnecting, last destination was /10.131.9.17:39404
===2019-07-12 11:11:02.630 INFO  io.lettuce.core.protocol.ReconnectionHandler Line:106 - Reconnected to 10.131.9.17:39404
===2019-07-12 11:12:05.366 INFO  io.lettuce.core.protocol.CommandHandler Line:116 - null Unexpected exception during request: java.io.IOException: The remote host forcibly closed an existing connection
java.io.IOException: The remote host forcibly closed an existing connection
    at sun.nio.ch.SocketDispatcher.read0(Native Method)
    at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43)
    at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)
    at sun.nio.ch.IOUtil.read(IOUtil.java:192)
    at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)
    at io.netty.buffer.PooledUnsafeDirectByteBuf.setBytes(PooledUnsafeDirectByteBuf.java:288)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1108)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:345)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:748)

redis服务器似乎关闭了连接,然后我的程序再次重新连接到它。

1 个答案:

答案 0 :(得分:0)

此问题是Redis设置错误。设置timeou = 0可以解决这个问题。

客户端空闲N秒后关闭连接(0禁用)

超时0