On liveliness changed call?

6 posts / 0 new
Last post
Offline
Last seen: 9 years 9 months ago
Joined: 03/02/2015
Posts: 4
On liveliness changed call?

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

Offline
Last seen: 9 years 9 months ago
Joined: 03/02/2015
Posts: 4

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.

Gerardo Pardo's picture
Offline
Last seen: 4 days 7 hours ago
Joined: 06/02/2010
Posts: 602

Hi,

It is a bit confusing... You need to configure the  liveliness.lease_duration both on the DataWriter and the DataReader.

On the DataWriter the setting of the lease_duration defines how often the DataWriter (or the DomainParticipant on its behalf) commits to announce its presence. It is a contract that is communicated to the DataReader. So the DataReader will take each specific DataWriter contract into consideration to make a determination of whether that DataWriter is alive. If the DataReader sees a DataWriter who does not meet the DataWriter's accounced lease-duration contract the DataReader will call on_liveliness_lost() for that DataWriter.

Thus the DataWriter liveliness.lease_duration controls the "definition" of whether the DataWriter is alive or not. 

The DataReader liveliness.lease_duration configures how often the DataReader checks 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 a DataReader can set its own  liveliness.lease_duration in accordance to how "quickly" it needs to detect the liveliness being lost.

By default both DataWrite and DataReader lease_duration are 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 the  liveliness.lease_duration only in the DataReader side. Basically the DataReader was checking faster but the DataWriter contact had an infinite lease_duration so it would never expire until Discovery kicked in...

Gerardo

 

 

Offline
Last seen: 9 years 9 months ago
Joined: 03/02/2015
Posts: 4

Hi Gerardo,

Thank you for the detailed response. I have set the lease_duration of 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 is on_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! 

 

Gerardo Pardo's picture
Offline
Last seen: 4 days 7 hours ago
Joined: 06/02/2010
Posts: 602

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

Offline
Last seen: 9 years 9 months ago
Joined: 03/02/2015
Posts: 4

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