Hi,
I'm having a problem with using on_liveliness_changed.
Following the C API, and editting the QoS as specified here: http://community.rti.com/rti-doc/510/ndds.5.1.0/doc/html/api_c/structDDS__LivelinessQosPolicy.html, I've tried setting the lease_duration to 1 second on the subscriber (data_reader). However whenever I terminate the publisher, it takes ~ 2 minutes before the on_liveliness_changed is called again.
I have also tried this in the subscriber, however still having the problem above.
struct DDS_DataReaderQos datareader_qos = DDS_DataReaderQos_INITIALIZER;
datareader_qos.liveliness.lease_duration.sec = 1;
datareader_qos.liveliness.lease_duration.nanosec = 0;
Am I missing something?
Thanks
To clarify what I am trying to achieve; as soon as a Publisher is disconnected, I would like the Subscriber to call a function which it would act upon, instead of creating for instance a watchdog with a timer.
Hi,
It is a bit confusing... You need to configure the
liveliness.lease_durationboth on theDataWriterand theDataReader.On the DataWriter the setting of the
lease_durationdefines how often the DataWriter (or the DomainParticipant on its behalf) commits to announce its presence. It is a contract that is communicated to theDataReader. So the DataReader will take each specificDataWritercontract into consideration to make a determination of whether thatDataWriteris alive. If theDataReadersees a DataWriter who does not meet the DataWriter's accounced lease-duration contract the DataReader will callon_liveliness_lost()for that DataWriter.Thus the DataWriter
liveliness.lease_durationcontrols the "definition" of whether the DataWriter is alive or not.The
DataReaderliveliness.lease_durationconfigures how often theDataReaderchecks that its matched DataWriters are still meeting their respective contracts. So even if the DataWriter's liveliness has expired the DataReader may not realize it (and thus not call the on_liveliness_lost()) until it looks at it . Because periodically checking for things takes time aDataReadercan set its ownliveliness.lease_durationin accordance to how "quickly" it needs to detect the liveliness being lost.By default both DataWrite and DataReader
lease_durationare infinite, so this call is only triggered when Discovery detects the loss of connectivity, which by default is configured with a fairly long timout (100 sec if I recall correctly). This explains why you are not getting these call-backs sooner when you configured theliveliness.lease_durationonly in the DataReader side. Basically the DataReader was checking faster but the DataWriter contact had an infinitelease_durationso it would never expire until Discovery kicked in...Gerardo
Hi Gerardo,
Thank you for the detailed response. I have set the
lease_durationof both the DataWriter and DataReader in the QoS to 1 second.For the
on_liveliness_lost()callback, is that only available for the DataWriter, as I am unable to find documentation for the DataReader? The closest I can find ison_liveliness_changed()for the DataReader, however that does not react in a timely manner when the DataWriter is terminated (or disconnected).I suppose what I am trying to ask is, what is the equivalent
on_liveliness_lost()callback for the DataReader to act on when a DataWriter loses connection? So that, as soon as a DataWriter is disconnected, the DataReader would act on the liveliness lost callback?Thanks!
Hi,
I did not fully understand. Did you mean that you want a DataWriter to detect when a (matched) DataReader is no longer there?
Gerardo
Hi Gerardo,
Afraid not - I'm trying to detect on a DataReader when it is no longer receiving data from a DataWriter, if that makes sense, or if that's a thing?
Thanks