有沒有辦法限制(或只是得到)在netty庫(版本4.x)的傳出連接的數量?如何限制Netty客戶端的傳出連接數量?
NioEventLoopGroup
中有nThreads
選項,它等於numberOfCpuCores * 2
,但每個線程對於許多連接都使用Selector
。
P.S.這是如何提出請求的。
Bootstrap b = new Bootstrap();
b.group(eventLoopGroup)
.channel(NioSocketChannel.class)
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
.handler(new MyHandler());
ChannelFuture cf = b.connect(host, port);
cf.addListener(new MyConnectionListener());
也許[UniqueIpFilter](http://netty.io/4.1/api/io/netty/handler/ipfilter/UniqueIpFilter.html)可以提供幫助嗎? – swKK