java.lang.IllegalStateException:failed to create a child event loop
2 io.netty.util.concurrent.MultithreadEventExecutorGroup.
3 ......
4 Caused by:
5 java.io.IOException:Too many open files
6 sun.nio.ch.IOUtil.makePipe(Native Method)
7 sun.nio.ch.PollSelectorImpl.
8 sun.nio.ch.PollSelectorProvider.openSelector(PollSelectorProvider.java:36)
9 io.netty.channel.nio.NioEventLoop.openSelector(SourceFile:124)
10 io.netty.channel.nio.NioEventLoop.
11 io.netty.channel.nio.NioEventLoopGroup.newChild(SourceFile:140)
12 io.netty.channel.nio.NioEventLoopGroup.newChild(SourceFile:31)
13 io.netty.util.concurrent.MultithreadEventExecutorGroup.
14 io.netty.util.concurrent.MultithreadEventExecutorGroup.
15 io.netty.channel.MultithreadEventLoopGroup.
16 io.netty.channel.nio.NioEventLoopGroup.
17 io.netty.channel.nio.NioEventLoopGroup.
18 io.netty.channel.nio.NioEventLoopGroup.
19 io.netty.channel.nio.NioEventLoopGroup.
20 com.ninexiu.sixninexiu.common.util.m.
21 com.ninexiu.sixninexiu.common.util.m.a(SourceFile:140)
22 com.ninexiu.sixninexiu.d.bm$3.run(SourceFile:1225)
23 android.os.Handler.handleCallback(Handler.java:761)
24 android.os.Handler.dispatchMessage(Handler.java:98)
25 android.os.Looper.loop(Looper.java:156)
26 android.app.ActivityThread.main(ActivityThread.java:6577)
27 java.lang.reflect.Method.invoke(Native Method)
28 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)
29 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831)
I use this version: netty-all-5.0.0.Alpha2.jar in Android app .
this is my init code
group = new NioEventLoopGroup();
bootstrap = new Bootstrap();
bootstrap.channel(NioSocketChannel.class);
bootstrap.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.SO_BACKLOG, 10000)
.option(ChannelOption.SO_REUSEADDR, true)
.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.SO_LINGER, 0)
.option(ChannelOption.SO_KEEPALIVE, true)
.option(ChannelOption.SO_RCVBUF, 8192)
.option(ChannelOption.SO_SNDBUF, 8192);
bootstrap.group(group);
bootstrap.handler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline channelPipeline = ch.pipeline();
channelPipeline.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 2, -2, 2));
channelPipeline.addLast(new MessageBinaryDecoder());
channelPipeline.addLast(new MessageEncoder());
channelPipeline.addLast(new ChatClientHandler(mHandler));
}
});
and this is my disconnect code
public void disconnect() {
try {
if(ch!=null){
ch.disconnect();
ch.close();
ch = null;
}
} catch (Exception e) {
e.printStackTrace();
}
}
I don't understand why cause this err.
Maybe you have opened too many connecitons. try lsof -n | grep pid to see if your app has too many open file, and increase the limitation by ulimit -n
5.0 has been abandoned. Please use the latest 4.1 release.
You will need to increase your open file limit if you already closing the connections probably.
yeah , limit create instance fix it .I will update to 4.1 release.
You can see "Too many open files" in exception trace which is caused when you have open file count more than allowed open file count. This happens either because you have FD leak or you need to increase FD limit which can be done by updating file /etc/security/limits.conf
How can this be fixed on a mac?
Most helpful comment
How can this be fixed on a mac?