I use bellow code to create reactor netty http client and use this client to send request.
ConnectionProvider connectionProvider = ConnectionProvider.builder("lead")
.maxConnections(10)
.pendingAcquireTimeout(Duration.ofSeconds(60))
.pendingAcquireMaxCount(10)
.maxLifeTime(Duration.ofSeconds(100))
.maxIdleTime(Duration.ofSeconds(60))
.build();
HttpClient httpClient = HttpClient.create(connectionProvider)
.keepAlive(true);
I loop send rquest:
for (; ; ) {
httpClient.get().uri("http://localhost:5230/test")
.response()
.subscribe();
}
I hope http client only create 10 connection to http server,but the result not as expected,client create many connection to http server(server listen on 5230 port)(this connection soon closed):
netstat -nap |grep "5230" output
TCP 127.0.0.1:5230 0.0.0.0:0 LISTENING 1980
TCP 127.0.0.1:5230 127.0.0.1:51012 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51014 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51015 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51016 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51017 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51018 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51019 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51020 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51021 ESTABLISHED 1980
TCP 127.0.0.1:5230 127.0.0.1:51022 ESTABLISHED 1980
TCP 127.0.0.1:50393 127.0.0.1:5230 TIME_WAIT 0
TCP 127.0.0.1:50394 127.0.0.1:5230 TIME_WAIT 0
TCP 127.0.0.1:50395 127.0.0.1:5230 TIME_WAIT 0
TCP 127.0.0.1:50396 127.0.0.1:5230 TIME_WAIT 0
TCP 127.0.0.1:50397 127.0.0.1:5230 TIME_WAIT 0
TCP 127.0.0.1:50398 127.0.0.1:5230 TIME_WAIT 0
TCP 127.0.0.1:50399 127.0.0.1:5230 TIME_WAIT 0
TCP 127.0.0.1:50400 127.0.0.1:5230 TIME_WAIT 0
TCP 127.0.0.1:50401 127.0.0.1:5230 TIME_WAIT 0
.... there is many connection in TIME_WAIT status....
How can i make sure http client only create 10 connection to http server?
Version:
jdk 1.8.0_201
reactory-netty 1.0.3
netty 4.15.9.Final