microwww / redis-mock

redis server for java, java redis mock
https://github.com/microwww/jedis-mock
Apache License 2.0
47 stars 18 forks source link

IOException: try to close channel #3

Closed 402293063 closed 3 years ago

402293063 commented 3 years ago

redisServer = new RedisServer(); redisServer.listener("127.0.0.1", 55555);

20-12-25 17:25:12,486 [] [pool-2-thread-1] INFO (Slf4jLogger.java info 30) - Redis server start @ 127.0.0.1:55555 2020-12-25 17:25:12,565 [] [pool-2-thread-5] INFO (Slf4jLogger.java error 50) - Error ! try to close channel : 远程主机强迫关闭了一个现有的连接。 java.io.IOException: 远程主机强迫关闭了一个现有的连接。 at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.8.0_261] at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[?:1.8.0_261] at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_261] at sun.nio.ch.IOUtil.read(IOUtil.java:197) ~[?:1.8.0_261] at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:378) ~[?:1.8.0_261] at com.github.microwww.redis.ChannelInputStream.tryRead(ChannelInputStream.java:32) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.ChannelInputStream.available(ChannelInputStream.java:47) ~[redis-server-0.1.0-3.0.jar:?] at java.io.FilterInputStream.available(FilterInputStream.java:168) ~[?:1.8.0_261] at com.github.microwww.redis.protocal.jedis.JedisInputStream.available(JedisInputStream.java:39) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.RedisServer.readChannel(RedisServer.java:86) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.SelectSocketsThreadPool.lambda$null$0(SelectSocketsThreadPool.java:45) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.TaskThread.scheduling(TaskThread.java:39) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.SelectSocketsThreadPool.lambda$readableHandler$2(SelectSocketsThreadPool.java:44) ~[redis-server-0.1.0-3.0.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_261] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_261] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_261] 2020-12-25 17:25:12,587 [] [pool-2-thread-5] INFO (Slf4jLogger.java info 30) - Remote KILLED: 127.0.0.1:53438

lichangshu commented 3 years ago

redisServer = new RedisServer(); redisServer.listener("127.0.0.1", 55555);

20-12-25 17:25:12,486 [] [pool-2-thread-1] INFO (Slf4jLogger.java info 30) - Redis server start @ 127.0.0.1:55555 2020-12-25 17:25:12,565 [] [pool-2-thread-5] INFO (Slf4jLogger.java error 50) - Error ! try to close channel : 远程主机强迫关闭了一个现有的连接。 java.io.IOException: 远程主机强迫关闭了一个现有的连接。 at sun.nio.ch.SocketDispatcher.read0(Native Method) ~[?:1.8.0_261] at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:43) ~[?:1.8.0_261] at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223) ~[?:1.8.0_261] at sun.nio.ch.IOUtil.read(IOUtil.java:197) ~[?:1.8.0_261] at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:378) ~[?:1.8.0_261] at com.github.microwww.redis.ChannelInputStream.tryRead(ChannelInputStream.java:32) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.ChannelInputStream.available(ChannelInputStream.java:47) ~[redis-server-0.1.0-3.0.jar:?] at java.io.FilterInputStream.available(FilterInputStream.java:168) ~[?:1.8.0_261] at com.github.microwww.redis.protocal.jedis.JedisInputStream.available(JedisInputStream.java:39) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.RedisServer.readChannel(RedisServer.java:86) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.SelectSocketsThreadPool.lambda$null$0(SelectSocketsThreadPool.java:45) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.TaskThread.scheduling(TaskThread.java:39) ~[redis-server-0.1.0-3.0.jar:?] at com.github.microwww.redis.SelectSocketsThreadPool.lambda$readableHandler$2(SelectSocketsThreadPool.java:44) ~[redis-server-0.1.0-3.0.jar:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_261] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_261] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_261] 2020-12-25 17:25:12,587 [] [pool-2-thread-5] INFO (Slf4jLogger.java info 30) - Remote KILLED: 127.0.0.1:53438

You can ignore this error because the server closed the channel incorrectly. I recently tried to fix it

lichangshu commented 3 years ago

We have no API to detect if the channel is closed, so If an IOException is caught, we assume that the client closed the connection automatically ! I changed the log level to DEBUG