diff --git a/code/DDSCodeTester.cpp b/code/DDSCodeTester.cpp index cf472f97f..1ed290221 100644 --- a/code/DDSCodeTester.cpp +++ b/code/DDSCodeTester.cpp @@ -6521,6 +6521,23 @@ void dds_transport_examples () //!-- } + { + //CONF-TCP-KEEP-ALIVE + DomainParticipantQos qos; + + // Create a descriptor for the new transport. + auto tcp_transport = std::make_shared(); + + // Configure keep alive options + tcp_transport->keep_alive_frequency_ms = 5000; // Send a keep-alive message every 5 seconds when connection is idle + tcp_transport->keep_alive_timeout_ms = 2000; // Consider connection lost if no response is received within 2 seconds + tcp_transport->keep_alive_thread = eprosima::fastdds::rtps::ThreadSettings{-1, 0, 0, -1}; // Configure thread settings + + // Link the Transport Layer to the Participant. + qos.transport().user_transports.push_back(tcp_transport); + //!-- + } + { //TRANSPORT-DESCRIPTORS DomainParticipantQos qos; diff --git a/code/XMLTester.xml b/code/XMLTester.xml index be156d0b7..ac32940a6 100644 --- a/code/XMLTester.xml +++ b/code/XMLTester.xml @@ -796,6 +796,21 @@ <--> +CONF-TCP-KEEP-ALIVE<--> + + + + keep_alive_transport + TCPv4 + 5000 + 25000 + + +<--> + CONF-DISABLE-MULTICAST<--> CONF-TCP-KEEP-ALIVE<--> + :end-before: <--> + :lines: 2-3, 6- + :append: + + .. tab-item:: C++ + :sync: cpp + + .. literalinclude:: ../../../../code/DDSCodeTester.cpp + :language: c++ + :dedent: 8 + :start-after: //CONF-TCP-KEEP-ALIVE + :end-before: //! + +.. note:: + + This feature is intended for TCP transports and only applies to connected TCP channels. diff --git a/docs/fastdds/use_cases/use_cases.rst b/docs/fastdds/use_cases/use_cases.rst index 008f136af..ee311ae9f 100644 --- a/docs/fastdds/use_cases/use_cases.rst +++ b/docs/fastdds/use_cases/use_cases.rst @@ -21,6 +21,12 @@ with distributed systems: If the network interfaces are expected to change while the application is running, *Fast DDS Pro* provides an automatic way of re-scanning the available interfaces and including them. ++ :ref:`TCP Keep Alive ` |Pro|. + In the same line as :ref:`IP mobility `, TCP Keep Alive feature allows to automatically detect + broken TCP connections by sending periodic keep-alive messages at application level when the connection is idle. + This feature is essential in TCP scenarios with dynamic IP changes or unstable network conditions, + ensuring that stale connections are identified and re-established promptly. + + :ref:`use-case-tcp`. Describes how to configure *Fast DDS* to use the ``LARGE_DATA`` builtin transports mode. This mode enables efficient utilization of TCP transport without the need for constant reconfiguration diff --git a/docs/fastdds/xml_configuration/transports.rst b/docs/fastdds/xml_configuration/transports.rst index 70c46df5c..06f25cf77 100644 --- a/docs/fastdds/xml_configuration/transports.rst +++ b/docs/fastdds/xml_configuration/transports.rst @@ -84,13 +84,13 @@ A more detailed explanation of each of these elements can be found in :ref:`comm - ``string`` - * - ```` - - Frequency in milliseconds for sending :ref:`RTCP ` keep-alive requests (TCP only). + - |Pro| Frequency in milliseconds for sending :ref:`RTCP ` keep-alive requests (TCP only). - ``uint32_t`` - - ``50000`` + - ``0`` * - ```` - - Time in milliseconds since the last keep-alive request was sent to consider a connection as broken (TCP only). + - |Pro| Time in milliseconds since the last keep-alive request was sent to consider a connection as broken (TCP only). - ``uint32_t`` - - ``10000`` + - ``0`` * - ```` - The maximum number of logical ports to try during :ref:`RTCP ` negotiations (TCP only). - ``uint16_t``