vert-x3 / vertx-consul-client

Vert.x Consul Client
Apache License 2.0
34 stars 23 forks source link

Watch key value: An existing connection was forcibly closed by the remote host #79

Open crazyliuzc opened 4 years ago

crazyliuzc commented 4 years ago

Version

3.9.3

Context

I encountered an exception which looks suspicious while ...

        Vertx vertx = Vertx.vertx();
        ConsulClientOptions options = new ConsulClientOptions()
                .setHost("192.168.6.107")
                .setPort(8500)
                .setTimeout(50000)
                .setLogActivity(false);
        for (int i = 0; i < 300; i++) {
            final int finalI = i;
            Watch<KeyValue> watch = Watch.key("test123"+i, vertx, options);
            watch.setHandler(keyValueWatchResult -> {
                if (keyValueWatchResult.succeeded()) {
                    KeyValue keyValue = keyValueWatchResult.nextResult();
                    log.info("{} Monitor timer:{}",finalI,keyValue.toJson().encodePrettily());
                } else {
                    log.error(finalI+" watch error" ,keyValueWatchResult.cause());
                    watch.stop();
                }
            }).start();
        }

I set timeout for a request is 50s. Start the Watch 300 times, some success, some error. This is error:

 java.io.IOException: An existing connection was forcibly closed by the remote host
    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:377)
    at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253)
    at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1133)
    at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:148)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.lang.Thread.run(Thread.java:821)

Do you have a reproducer?

https://github.com/crazyliuzc/test-vertx-consul

Extra