【发布时间】:2015-12-17 17:28:48
【问题描述】:
有没有办法限制(或只是获取)netty 库(4.x 版)中的传出连接数?
NioEventLoopGroup 中有nThreads 选项,它等于numberOfCpuCores * 2,但每个线程使用Selector 进行许多连接。
附:这就是提出请求的方式。
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 可以帮忙?