@Override
    public void initChannel(SocketChannel ch) throws Exception {

        boolean isClientConnection = configuration.getType() == ConnectionType.SOCKET_C2S;

        NettyConnectionHandler businessLogicHandler = NettyConnectionHandlerFactory.createConnectionHandler(configuration);
        Duration maxIdleTimeBeforeClosing = businessLogicHandler.getMaxIdleTime().isNegative() ? Duration.ZERO : businessLogicHandler.getMaxIdleTime();

        ch.pipeline()
            .addLast(TRAFFIC_HANDLER_NAME, new ChannelTrafficShapingHandler(0))
            .addLast("idleStateHandler", new IdleStateHandler(maxIdleTimeBeforeClosing.dividedBy(2).toMillis(), 0, 0, TimeUnit.MILLISECONDS))
            .addLast("keepAliveHandler", new NettyIdleStateKeepAliveHandler(isClientConnection))
            .addLast(new NettyXMPPDecoder())
            .addLast(new StringEncoder(StandardCharsets.UTF_8))
            .addLast("stalledSessionHandler", new WriteTimeoutHandler(Math.toIntExact(WRITE_TIMEOUT_SECONDS.getValue().getSeconds())))
            .addLast(businessLogicHandler);

        // Add ChannelHandler providers implemented by plugins, if any.
        channelHandlerFactories.forEach(factory -> {
            try {
                factory.addNewHandlerTo(ch.pipeline());
            } catch (Throwable t) {
                Log.warn("Unable to add ChannelHandler from '{}' to pipeline of new channel: {}", factory, ch, t);
            }
        });

        if (isDirectTLSConfigured()) {
            ch.attr(CONNECTION).get().startTLS(false, true);
        }

        allChannels.add(ch);
    }
Controls the write timeout time in seconds to handle stalled sessions and prevent DoS
xmppserver/src/main/java/org/jivesoftware/openfire/spi/NettyServerInitializer.java