We are using a DataWriterListener
and want to log the IP address of a DataReader
whenever it disconnects abruptly. Specifically, we want to log a message like:
"Reader with IP X.X.X.X disconnected unexpectedly."
Is the on_liveliness_lost
callback the correct method to detect such disconnections? If so, how can we log the reader's IP address from within this callback?
Additionally, are there any QoS settings on the DataWriter side that we can configure to help detect or handle such disconnections more effectively?
It's not that straight forward to do what you want since a DataReader may have multiple IP addresses associated with it, or may have none.
You would have to lookup the ParticipantBuiltinTopicData by first converting the remote participant's key (found in the SubscriptionBuiltinTopicData) into an instance handle for the remote participant with DDS_BuiltinTopicKey_to_instance_handle, and then using get_discovered_participant_data().
and in the ParticipantBuiltinTopicData, there is the default_locators sequence which contains the addresses of the remote participant that contained the DataReader that "disconnected".
I suggest using RTI's chatbot @ https://chatbot.rti.com. I was able to get a useful answer by asking your question (and then a followup question for more details about extracting the IP address from the ParticipantBuiltinTopicData).
What do you mean by "more effectively"?