Search code examples
acepublishersubscriberdata-distribution-servicetao

OpenDDS - message_writer->write(...) error DDS::RETCODE_TIMEOUT


I'm creating an simple message program in openDDS. This program uses a publisher and a subscriber. In the publisher I write a message with:

DDS::ReturnCode_t error = message_writer->write(message, DDS::HANDLE_NIL);

When I try to send from 180 bytes to 3012 bytes the writer fails with:

error 10 (== DDS::RETCODE_TIMEOUT)

, after about 260 messages (I'm trying to send 1500 messages). What I find strange is that it works when I send messages that are from 1 <= x < 180 and 3012 > x > 102400+ bytes.

I'm receiving the error on the writer side. Below the writer I do:

if (error != DDS::RETCODE_OK) { 
    std::cerr << "writer failed because of error" << error << std::endl; 
}

my idl file is like so:

module Mess { 
    struct Mes { 
        string message; 
    };}; 

So this uses TAO string manager. I pass a char* into the message.

Messenger::Message message;

message.message = "some_Message"; 

Then write the message like before

Participant:

DDS::DomainParticipant_var participant = dpf->create_participant(DOMAIN_ID, PARTICIPANT_QOS_DEFAULT, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK);

Topic:

DDS::Topic_var topic = participant->create_topic("TopicName", type_name, TOPIC_QOS_DEFAULT, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK);

Publisher:

DDS::Publisher_var publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK);

Writer:

DDS::DataWriter_var writer = publisher->create_datawriter(topic, DATAWRITER_QOS_DEFAULT, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK);

Any help is well appreciated. Thanks!


Solution

  • I found out the problem. The reason for this was because my application was publishing faster than the network can distribute the samples. The fix was to use the following Qos on the DataWriter:

    DDS::DataWriterQos dw_qos;
    pub->get_default_datawriter_qos (dw_qos);
    dw_qos.history.kind = DDS::KEEP_ALL_HISTORY_QOS;
    dw_qos.reliability.kind = DDS::RELIABLE_RELIABILITY_QOS;
    dw_qos.reliability.max_blocking_time.sec = 22;
    dw_qos.reliability.max_blocking_time.nanosec = 0;
    dw_qos.resource_limits.max_samples_per_instance = 5;
    DDS::DataWriter_var dw = pub->create_datawriter(topic, dw_qos, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK);
    

    This data writer has the following behaviors:

    Can queue up to 5 samples that are pending delivery to one or more Subscribers.

    If 5 samples are pending, then a write call blocks for up to 22 seconds waiting for an opening in the queue.

    If an opening does not occur then the write call will return DDS::RETCODE_TIMEOUT instead of RETCODE_OK.

    Thanks for all the help!