@Override
    public void run() {

        /*
         * Here a driver reconnection is detected. If so, a connection event
         * is generated, so the user application can generate its requests again.
         */
        if (channel.attr(S7HMuxImpl.WAS_CONNECTED).get() &&
            channel.attr(S7HMuxImpl.IS_CONNECTED).get()) {
            channel.attr(S7HMuxImpl.WAS_CONNECTED).set(false);
            channel.pipeline().fireUserEventTriggered(new ConnectedEvent());
        }

        /*
         * Execute the ping towards the PLC. Its purpose is to keep
         * the TCP channel active, for very long sampling periods.
         */
        if (channel.attr(S7HMuxImpl.IS_PING_ACTIVE).get()) {
            if (slicePing >= channel.attr(S7HMuxImpl.PING_TIME).get()) {
                ping();
                slicePing = 0;
            }
            slicePing++;
        } else {
            slicePing = 0;
        }

        /*
         * Here it is verified if the channels are active. If they are not,
         * the connection is created again.
         * For H type systems, at least one of the connections must be active,
         * and if the other is down, the connection must be lifted.
         * S7HMuxImpl, includes the switching logic between the TCP links.
         */
        if (sliceRetryTime >= channel.attr(S7HMuxImpl.RETRY_TIME).get()) {

            if (primaryChannel != null) {
                if (!primaryChannel.isActive()) {
                    logger.info("Creating primary connection.");
                    primaryChannel.eventLoop().shutdownGracefully();
                    doPrimaryTcpConnections();
                } else if (null == secondaryChannel) {
                    if (channel.attr(S7HMuxImpl.WAS_CONNECTED).get() &&
                        !channel.attr(S7HMuxImpl.IS_CONNECTED).get()) {
                        logger.info("Reconnecting primary channel.");                       
                        if (null != ((S7HMux) s7hmux).getTCPChannel()) {
                            ((S7HMux) s7hmux).setPrimaryChannel(primaryChannel);
                        }
                    }
                }
            } else {
                logger.info("Creating first primary connection.");
                doPrimaryTcpConnections();
            }

            if (secondaryChannel != null) {
                if (!secondaryChannel.isActive()) {
                    logger.info("Creating secondary connection.");
                    secondaryChannel.eventLoop().shutdownGracefully();
                    doSecondaryTcpConnections();
                } else if (null == primaryChannel) {
                    if ((channel.attr(S7HMuxImpl.WAS_CONNECTED).get()) &&
                        (!channel.attr(S7HMuxImpl.IS_CONNECTED).get())) {
                        logger.info("Reconnecting secondary channel.");                       
                        if (null != ((S7HMux) s7hmux).getTCPChannel()) {
                            ((S7HMux) s7hmux).setSecondaryChannel(secondaryChannel);
                        }
                    }
                }
            } else {
                if (secondaryChannelFactory != null) {
                    logger.info("Creating first secondary connection.");
                    doSecondaryTcpConnections();
                }
            }
            sliceRetryTime = 0;
        }

        if (channel.attr(S7HMuxImpl.RETRY_TIME).get() > 0) {
            sliceRetryTime++;
        }

        connected = channel.attr(S7HMuxImpl.IS_CONNECTED).get();
        logger.trace("*************************************************\r\n"
            + "INSTAMCIA PRIMARIO      : " + ((null == primaryChannel) ? "NULL" : primaryChannel.toString()) + "\r\n"
            + "ACTIVO PRIMARIO         : " + ((null == primaryChannel) ? "NULL" : primaryChannel.isActive()) + "\r\n"
            + "INSTAMCIA SECUNDARIO    : " + ((null == secondaryChannel) ? "NULL" : secondaryChannel.toString()) + "\r\n"
            + "ACTIVO SECUNDARIO       : " + ((null == secondaryChannel) ? "NULL" : secondaryChannel.isActive()) + "\r\n"
            + "CANAL CONECTADO?        : " + channel.attr(S7HMuxImpl.IS_CONNECTED).get() + "\r\n"
            + "CANAL ESTUVO CONECTADO? : " + channel.attr(S7HMuxImpl.WAS_CONNECTED).get() + "\r\n"
            + "CONTADORES              : " + slicePing + " : " + sliceRetryTime + "\r\n"
            + "*************************************************");
    }
Subscriptions are only supported in a small subset of the S7 devices.

@return true, if the device supports subscriptions.
plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HPlcConnection.java