Android - Netty - RejectedExecutionException

Android - Netty - RejectedExecutionException

我带着棘手的问题回来了。

我已经为我们的 Android 项目编写了一个 netty 服务器,但有时,当我尝试向连接的客户端发送内容时,我收到 RejectedExecutionException。

03-17 22:07:49.938 21708-22346/htlhallein.at.serverdatenbrille_rewritten E/AndroidRuntime﹕ FATAL EXCEPTION: Thread-9824 Process: htlhallein.at.serverdatenbrille_rewritten, PID: 21708 java.util.concurrent.RejectedExecutionException: event executor terminated at io.netty.util.concurrent.SingleThreadEventExecutor.reject(SingleThreadEventExecutor.java:707) at io.netty.util.concurrent.SingleThreadEventExecutor.addTask(SingleThreadEventExecutor.java:299) at io.netty.util.concurrent.SingleThreadEventExecutor.execute(SingleThreadEventExecutor.java:690) at io.netty.channel.AbstractChannel$AbstractUnsafe.register(AbstractChannel.java:421) at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:60) at io.netty.channel.SingleThreadEventLoop.register(SingleThreadEventLoop.java:48) at io.netty.channel.MultithreadEventLoopGroup.register(MultithreadEventLoopGroup.java:64) at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:315) at io.netty.bootstrap.AbstractBootstrap.doBind(AbstractBootstrap.java:271) at io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:267) at io.netty.bootstrap.AbstractBootstrap.bind(AbstractBootstrap.java:242) at htlhallein.at.serverdatenbrille_rewritten.server.DatenbrillenServer$Server.run(DatenbrillenServer.java:172) at java.lang.Thread.run(Thread.java:841)

我不确定我应该选择哪个 Event Executor? 异常在 运行 服务器之后的一行被触发。 (Log.d(DatenbrillenServer.class.toString(), "Stopped Server ...");)

有没有人有想法,为什么会这样?

非常感谢!

当您在调用 shutdownGracefully() 后尝试执行 IO 时会发生这种情况。确保在调用之前完成所有 IO