Netty服务器在通道关闭时未发送所有数据

Netty服务器在通道关闭时未发送所有数据,netty,Netty,我是netty的新手,不明白为什么服务器响应在我的服务器中部分丢失。我已经读了一些问题贴,但我不能解决这个问题 我使用的是netty 4.0.46版本。 服务器发送所有响应数据后必须关闭连接。 我正在使用SimpleChannelInboundHandler,并尝试在发送响应后使用ChannelFutureListener关闭通道 public class AlbaranXMLServerHandler extends SimpleChannelInboundHandler<String&

我是netty的新手,不明白为什么服务器响应在我的服务器中部分丢失。我已经读了一些问题贴,但我不能解决这个问题

我使用的是netty 4.0.46版本。 服务器发送所有响应数据后必须关闭连接。 我正在使用SimpleChannelInboundHandler,并尝试在发送响应后使用ChannelFutureListener关闭通道

public class AlbaranXMLServerHandler extends SimpleChannelInboundHandler<String> {
...
    @Override
    public void channelActive(ChannelHandlerContext ctx) throws Exception {
        String host = ((InetSocketAddress)ctx.channel().remoteAddress()).getAddress().getHostAddress();
        int port = ((InetSocketAddress)ctx.channel().remoteAddress()).getPort();
        logger.debug(String.format("Nueva conexión. host:%s port:%d", host, port));
    }

@Override
public void channelRead0(ChannelHandlerContext ctx, String request)
        throws Exception {

    logger.info("Request received: " + request);
    .......

    logger.debug("XML Response: " + response);  

    ChannelFuture future = ctx.writeAndFlush(response);
    future.addListener(ChannelFutureListener.CLOSE);
    .......
}
public class AlbaranXMLServerInitializer extends ChannelInitializer<SocketChannel> {
......
    @Override
    public void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();

        // Add the text line codec combination first,
        pipeline.addLast("framer", new FixedLengthFrameDecoder(AlbaranXMLServerHandler.TRAMA_PETICION_LONGITUD));
        // the encoder and decoder are static as these are sharable
        pipeline.addLast("decoder", DECODER);
        pipeline.addLast("encoder", ENCODER);

        // and then business logic.
        pipeline.addLast("handler", new AlbaranXMLServerHandler(rutaAlbaranes, autenticacionRFCService, albaranXMLRFCService, grupoSociedadesRFCService));
    }
}
            @Service 
public class AlbaranXMLServer extends SocketServerBase {
    logger.info("Inicializando el servicio " + this.getClass().getSimpleName() + " ...");

            bossGroup = new NioEventLoopGroup();
            workerGroup = new NioEventLoopGroup();

            try {
                ServerBootstrap b = new ServerBootstrap();
                b.group(bossGroup, workerGroup)
                        .channel(NioServerSocketChannel.class)
                        .childHandler(this.getChannelInitializer());

                Channel channel = b.bind(port).sync().channel();
                logger.info("Finalizada la inicialización del servicio " + this.getClass().getSimpleName());

            } catch (Exception e) {
                logger.warn("Error al inicializar el servicio " + this.getClass().getSimpleName(), e);
                bossGroup.shutdownGracefully();
                workerGroup.shutdownGracefully();
            }