how to fix this java.lang.IllegalStateException:failed to create a child event loop err
See original GitHub issuejava.lang.IllegalStateException:failed to create a child event loop 2 io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(SourceFile:99) 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.<init>(PollSelectorImpl.java:57) 8 sun.nio.ch.PollSelectorProvider.openSelector(PollSelectorProvider.java:36) 9 io.netty.channel.nio.NioEventLoop.openSelector(SourceFile:124) 10 io.netty.channel.nio.NioEventLoop.<init>(SourceFile:118) 11 io.netty.channel.nio.NioEventLoopGroup.newChild(SourceFile:140) 12 io.netty.channel.nio.NioEventLoopGroup.newChild(SourceFile:31) 13 io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(SourceFile:95) 14 io.netty.util.concurrent.MultithreadEventExecutorGroup.<init>(SourceFile:68) 15 io.netty.channel.MultithreadEventLoopGroup.<init>(SourceFile:49) 16 io.netty.channel.nio.NioEventLoopGroup.<init>(SourceFile:100) 17 io.netty.channel.nio.NioEventLoopGroup.<init>(SourceFile:71) 18 io.netty.channel.nio.NioEventLoopGroup.<init>(SourceFile:56) 19 io.netty.channel.nio.NioEventLoopGroup.<init>(SourceFile:41) 20 com.ninexiu.sixninexiu.common.util.m.<init>(SourceFile:71) 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.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
How can this be fixed on a mac?
5.0 has been abandoned. Please use the latest 4.1 release.