I have a weird issue with Vert.x 3.7.0 and 3.7.1: HttpRequest send methods which transmit data in the request body (sendForm(), sendJson(), sendBuffer() etc. - all except send()) would never return, if the host is not available.
The following code never returns, if there's no server on port 4012:
HttpClientOptions options = new HttpClientOptions()
.setDefaultHost("localhost")
.setDefaultPort(4012);
Vertx vertx = Vertx.vertx();
WebClient webClient = WebClient.create(vertx, new WebClientOptions(options));
HttpRequest<Buffer> request = webClient.request(HttpMethod.POST, "/test");
logger.info("Sending request as sendForm()");
request.sendForm(MultiMap.caseInsensitiveMultiMap(), event -> {
if (event.failed()) {
logger.error("Failed!", event.cause());
} else {
logger.info("Succeeded! Code {} {}", event.result().statusCode(), event.result().statusMessage());
}
vertx.close();
});
If I use request.send(event -> {...}) instead, then it prints (as expected):
27.06.19 16:47:17,352 ERROR - Failed! io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:4012
at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:779)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:632)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:579)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:496)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:458)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:897)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.net.ConnectException: Connection refused: no further information
... 11 more
There's no issue with Vert.x prior to 3.7.0: I tried 3.6.3, and both send() and sendForm() return with java.net.ConnectException: Connection refused: no further information. That's why I suspect it's a bug (in Vert.x, or maybe in underlying io.netty), unless I'm doing something with undefined behavior in my code.
Anybody from Vert.x community here? :)
Thanks in advance for any help.
P.S. I'm on Windows 10, Java using JVM Amazon Corretto 11.0.3.