When I use TCP client with fixed ConnectionProvider, I can't reuse connection.
They made connection exceed maxConnection variable.
This is what i wrote.
Even if I user 10 maxConnection like 'ConnectionProvider.fixed("TEST", 10)', there are 22 idle connection. omg
//NettyClient.java
@AllArgsConstructor
public class NettyClient {
private final int port;
public final ConnectionProvider connectionProvider = ConnectionProvider.fixed("TEST", 10);
public void sendTest() {
TcpClient c = TcpClient
.create(connectionProvider)
.port(port)
.handle((in, out) -> {
return out
.sendString(Mono.just("string"))
.then(in
.receive()
.asString()
.flatMap(ss -> {
out.withConnection(connection -> {
connection.disposeNow();
});
return Mono.empty();
}));
})
.option(ChannelOption.SO_KEEPALIVE, true)
.wiretap(true);
c.connect().subscribe();
}
}
//NettyClientTest.java
public class NettyClientTest {
@Test
public void send() throws InterruptedException {
NettyClient nettyClient = new NettyClient(11);
for (int i = 0; i < 20; i++) {
nettyClient.sendTest();
}
nettyClient.sendTest();
nettyClient.sendTest();
}
}
14:55:27.397 [reactor-tcp-nio-5] DEBUG reactor.netty.resources.PooledConnectionProvider - [id: 0x3444910e, L:/0:0:0:0:0:0:0:1:53928 ! R:/0:0:0:0:0:0:0:1:33333] Channel cleaned, now 0 active connections and 22 inactive connections