How to check which DataReader is not responding in your system
In complex systems, it may happen that one node gets overloaded and it stops communicating (or communicate slower) with remote nodes. If this node contains a DataReader that is subscribed to a topic along with other remote DataReaders, it can make the other DataReaders stop receiving data when the communication is reliable. RTI Connext can be configured to avoid such situations by using:
- DDS_RtpsReliableWriterProtocol_t::max_heartbeat_retries: to make non responding DataReaders not to block the DataWriter.
- DDS_RtpsReliableWriterProtocol_t::inactivate_nonprogressing_readers: to make non progressing DataReaders not to block the DataWriter.
From the DataWriter point of view, it is possible to know which DataReader is causing this situation (i.e., it is falling behind in reading the data it receives). In order to do this, The DataWriter needs to implement the on_reliable_reader_activity_changed callback and show the information in the DDS_ReliableReaderActivityChangedStatus. The following implementation prints the InstanceHandle of the remote DataReader causing the problem/falling behind, its IP address and its Topic Name (since it is the same as the local Topic Name). In this example, the Topic Name is saved as a static variable when the topic is created:
void exampleListener_on_reliable_reader_activity_changed( void* listener_data, DDS_DataWriter* writer, const struct DDS_ReliableReaderActivityChangedStatus *status) { int i; if (status->inactive_count_change > 0) { printf("[CALLBACK - on_reliable_reader_activity_changed]\n"); printf("\tStatus: %d active and %d inactive\n", status->active_count, status->inactive_count); printf("\tReader InstanceHandle: "); for (i = 0; i < 16; i++) { printf("%d ", status->last_instance_handle.keyHash.value[i]); } printf("\n"); printf("\tThe IP Address is: %d.%d.%d.%d\n",status->last_instance_handle.keyHash.value[0], status->last_instance_handle.keyHash.value[1], status->last_instance_handle.keyHash.value[2], status->last_instance_handle.keyHash.value[3]); printf("\tThe topic name is: %s\n", topic_name); } }
This is an example of how to gather part of the information that RTI Connext provides via callbacks and statuses.