我写了一个小的netty服务器程序。它适用于所有手机,但服务器只发送Android移动(客户端)的RST请求。有些时候工作正常,但有些时候遇到了问题。
帮助我。
ChannelFactory factory = new NioServerSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
bootstrap = new ServerBootstrap(factory);
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() {
// new SslHandler(getSSLEngine()),
return Channels.pipeline(
new MobileDecoder(),
new MobileChannelHandler(MobileMessageHandler
.getInstance()));
}
});
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
bootstrap.bind(new InetSocketAddress(9083));
答案 0 :(得分:1)
您可能想尝试OioServerSocketChannelFactory
。很多Android设备都附带了错误的NIO实现。