Unknown error happening

12 posts / 0 new
Last post
Offline
Last seen: 4 years 9 months ago
Joined: 05/21/2014
Posts: 46
Unknown error happening

When I am trying to send a file in a message using RTI DDS I keep getting this error and can not decode its meaning for how to fix it. The file is only of 2kb size as of note.

com.rti.dds.infrastructure.RETCODE_ERROR: Unexpected string length: 2320 > 1023
at com.rti.dds.cdr.CdrOutputStream.writeString(Unknown Source)
at com.rti.dds.type.builtin.StringTypeSupport.serialize(Unknown Source)
at com.rti.dds.topic.TypeSupportImpl.serializeI(Unknown Source)
at com.rti.dds.publication.DataWriterImpl.DDS_DataWriter_write_untypedI(Native Method)
at com.rti.dds.publication.DataWriterImpl.write_untyped(Unknown Source)
at com.rti.dds.type.builtin.StringDataWriter.write(Unknown Source)
at publisher.main(publisher.java:80)
PRESWriterHistoryDriver_initializeSample:!serialize
WriterHistoryMemoryPlugin_addEntryToSessions:!initialize sample
WriterHistoryMemoryPlugin_getEntry:!add virtual sample to sessions
WriterHistoryMemoryPlugin_addSample:!get entry
PRESWriterHistoryDriver_addWrite:!add_sample
PRESPsWriter_writeInternal:!collator addWrite
com.rti.dds.infrastructure.RETCODE_ERROR
at com.rti.dds.util.Utilities.rethrow(Unknown Source)
at com.rti.dds.infrastructure.RETCODE_ERROR.check_return_codeI(Unknown Source)
at com.rti.dds.publication.DataWriterImpl.write_untyped(Unknown Source)
at com.rti.dds.type.builtin.StringDataWriter.write(Unknown Source)
at publisher.main(publisher.java:80)
Exiting...
Exception in thread "main"

rip
rip's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 04/06/2012
Posts: 324

Unexpected string length: 2320 > 1023

The defined type includes a string field defined something like:

    string<1023> aString;

and you are trying to send a 2320 byte long string.  The rest of the error messages we can try to address after you've resolved the initial problem in your code.

There is a qos property setting for defining the length supported for the built-in StringDataWriter (see Table 3.1 on pdf page 68, Properties for Allocating Size of Built-in Types).  Note that if you change the size for Application A, you have to also change the size for Application B or they will still not communicate.

 

Offline
Last seen: 4 years 9 months ago
Joined: 05/21/2014
Posts: 46

Thanks. I was able to solve the part of where to put this in the code since I decided to change the QOS policy file in the code. By doing

 

PropertyQosPolicyHelper.add_property(datawriter_qos.property,"dds.builtin_type.string.alloc_size" ,"2048" ,true);
PropertyQosPolicyHelper.add_property(datawriter_qos.property, "dds.builtin_type.string.max_size", "2048",true);

 

However now a new problem has appeared from this.

 

PRESTypePluginDefaultEndpointBuiltinTypeConfigData_initialize:invalid property dds.builtin_type.string.max_size
TypeSupportNativePeer_on_endpoint_attached:!init builtin type config data
PRESPsService_enableLocalEndpointWithCursor:failed to attach endpoint to typePlugin
PRESPsService_enableLocalEndpoint:!enable local endpoint

 

rip
rip's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 04/06/2012
Posts: 324

max_size isn't a datawriter_qos property, it's a participant_qos property.  See section 3.2.7 of the Users Manual PDF, and Table 3-16 on page 3-90.

Offline
Last seen: 4 years 9 months ago
Joined: 05/21/2014
Posts: 46

I did 

PropertyQosPolicyHelper.add_property(dp_qos.property,"dds.builtin_type.string.max_size","2050",true);

and now get 

PRESTypePluginDefaultEndpointBuiltinTypeConfigData_initialize:inconsistent values: dds.builtin_type.string.alloc_size and dds.builtin_type.string.max_size

rip
rip's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 04/06/2012
Posts: 324

Can you supply all the code around the configuration and creation of your QoS/entities, for both the participant and the writer entity.

Offline
Last seen: 4 years 9 months ago
Joined: 05/21/2014
Posts: 46

code 

import java.io.BufferedReader;

import java.io.IOException;
import java.io.InputStreamReader;

import com.rti.dds.domain.DomainParticipant;
import com.rti.dds.domain.DomainParticipantFactory;
import com.rti.dds.domain.DomainParticipantFactoryQos;
import com.rti.dds.domain.DomainParticipantQos;
import com.rti.dds.infrastructure.InstanceHandle_t;
import com.rti.dds.infrastructure.PropertyQosPolicyHelper;
import com.rti.dds.infrastructure.RETCODE_ERROR;
import com.rti.dds.infrastructure.StatusKind;
import com.rti.dds.publication.DataWriterQos;
import com.rti.dds.publication.Publisher;
import com.rti.dds.subscription.DataReader;
import com.rti.dds.subscription.DataReaderListener;
import com.rti.dds.subscription.LivelinessChangedStatus;
import com.rti.dds.subscription.RequestedDeadlineMissedStatus;
import com.rti.dds.subscription.RequestedIncompatibleQosStatus;
import com.rti.dds.subscription.SampleLostStatus;
import com.rti.dds.subscription.SampleRejectedStatus;
import com.rti.dds.subscription.SubscriptionMatchedStatus;
import com.rti.dds.topic.Topic;
import com.rti.dds.type.builtin.StringDataWriter;
import com.rti.dds.type.builtin.StringTypeSupport;

import java.lang.reflect.Field;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;

import org.xml.sax.SAXException;
public class publisher{

public static void main(String[] args) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ParserConfigurationException, SAXException, TransformerFactoryConfigurationError, TransformerException
{
//System.load("C:\\Program Files\\RTI\\ndds.5.1.0\\lib\\x64Win64jdk\\nddsc.dll");
//System.load("C:\\Program Files\\RTI\\ndds.5.1.0\\lib\\x64Win64jdk\\nddsjavad.dll");
//System.load("C:\\Program Files\\RTI\\ndds.5.1.0\\lib\\x64Win64jdk\\nddscd.dll");
//System.load("C:\\Program Files\\RTI\\ndds.5.1.0\\lib\\x64Win64jdk\\nddscore.dll");
//System.load("C:\\Program Files\\RTI\\ndds.5.1.0\\lib\\x64Win64jdk\\nddscored.dll");
//System.load("C:\\Program Files\\RTI\\ndds.5.1.0\\lib\\x64Win64jdk\\nddsjava.dll");
//System.load("C:\\Program Files\\RTI\\ndds.5.1.0\\lib\\x64Win64jdk\\nddsjavad.dll");
DomainParticipantQos dp_qos = new DomainParticipantQos();
//PropertyQosPolicyHelper.add_property(dp_qos.property,"dds.builtin_type.string.max_size","2050",true);
DomainParticipant participant = DomainParticipantFactory.get_instance().create_participant(0,DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT, null,StatusKind.STATUS_MASK_NONE);
participant.get_qos(dp_qos);
PropertyQosPolicyHelper.add_property(dp_qos.property,"dds.builtin_type.string.max_size","2050",true);
participant = DomainParticipantFactory.get_instance().create_participant(0,DomainParticipantFactory.PARTICIPANT_QOS_DEFAULT, null,StatusKind.STATUS_MASK_NONE);
//PropertyQosPolicyHelper.add_property(dp_qos.property,"dds.builtin_type.string.max_size","2050",true);
DomainParticipantFactoryQos factoryQos =
new DomainParticipantFactoryQos();
factoryQos.profile.url_profile.setMaximum(1);
factoryQos.profile.url_profile.add("C:\\Users\\jricles\\Desktop\\custom_qos.xml");
DomainParticipantFactory.TheParticipantFactory.set_qos(factoryQos);
DomainParticipantFactory.TheParticipantFactory.get_qos(factoryQos);
if (participant == null)
{
System.err.println("Unable to create domain participant");
return;
}
Publisher publisher = participant.create_publisher(
DomainParticipant.PUBLISHER_QOS_DEFAULT, null /* listener */,
StatusKind.STATUS_MASK_NONE);
Topic topic = participant.create_topic(
"Event Logging",
StringTypeSupport.get_type_name(),
DomainParticipant.TOPIC_QOS_DEFAULT,
null, // listener
StatusKind.STATUS_MASK_NONE);
if (topic == null)
{
System.err.println("Unable to create topic.");
return;
}
DataWriterQos datawriter_qos = new DataWriterQos();
//publisher.set_default_library("C:\\Users\\jricles\\Desktop\\custom_qos.xml");
//participant.set_default_profile("BuiltinExampleLibrary","BuiltinExampleProfile");
StringDataWriter dataWriter =
(StringDataWriter) participant.create_datawriter(
topic,
Publisher.DATAWRITER_QOS_DEFAULT,
null, // listener
StatusKind.STATUS_MASK_NONE);
if (dataWriter == null)
{
System.err.println("Unable to create data writer\n");
return;
}
//DataWriterQos writerQos = new DataWriterQos();
participant.get_default_datawriter_qos(datawriter_qos);
//PropertyQosPolicyHelper.add_property(writerQos.property,"dds.builtin_type.string.alloc_size" ,"2048" ,true);
//PropertyQosPolicyHelper.add_property(dp_qos.property,"dds.builtin_type.string.max_size","2049",true);
//PropertyQosPolicyHelper.add_property(writerQos.property, "dds.builtin_type.string.max_size", "2048",true);
PropertyQosPolicyHelper.add_property(datawriter_qos.property,"dds.builtin_type.string.alloc_size" ,"2048" ,true);
//PropertyQosPolicyHelper.add_property(datawriter_qos.property, "dds.builtin_type.string.max_size", "2048",true);
dataWriter =
(StringDataWriter) publisher.create_datawriter(topic, datawriter_qos,
null, StatusKind.STATUS_MASK_NONE);
System.out.println("Ready to write data.");
System.out.println("When the subscriber is ready, you can start writing.");
System.out.print("Press CTRL+C to terminate or enter an empty line to do a clean shutdown.\n\n");
//BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
//xmlReader x = new xmlReader();
//System.out.println(dataWriter.get_topic().get_name());
System.out.print("Please type a message> ");
//System.out.println(xmlReader.main(args));
//double i = Math.ceil(xmlReader.main(args).length()/1023);
//int start = 0;
//int end = 1023;
String toWrite = xmlReader.main(args).toString();
dataWriter.write(toWrite, InstanceHandle_t.HANDLE_NIL);
/*
for(int j = 0; j<=i;j++)
{
if(end < xmlReader.main(args).length())
toWrite = xmlReader.main(args).substring(start,end).toString();
else
toWrite = xmlReader.main(args).substring(start, xmlReader.main(args).length()).toString();
dataWriter.write(toWrite, InstanceHandle_t.HANDLE_NIL);
start = end;
end = end+1023;
}
*/
} catch (IOException e) {
e.printStackTrace();
} catch (RETCODE_ERROR e) {
e.printStackTrace();
}
System.out.println("Exiting...");
participant.delete_contained_entities();
DomainParticipantFactory.get_instance().delete_participant(participant);
}
}

rip
rip's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 04/06/2012
Posts: 324
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import com.rti.dds.domain.*;
import com.rti.dds.infrastructure.*;
import com.rti.dds.publication.*;
import com.rti.dds.subscription.*;
import com.rti.dds.topic.Topic;
import com.rti.dds.type.builtin.*;

import java.lang.reflect.Field;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactoryConfigurationError;

import org.xml.sax.SAXException;
public class Foo {

    public static void main(String[] args) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ParserConfigurationException, SAXException, TransformerFactoryConfigurationError, TransformerException
    {
        DomainParticipantQos dp_qos = new DomainParticipantQos();
        DomainParticipantFactory.get_instance().get_default_participant_qos(dp_qos);
        PropertyQosPolicyHelper.add_property(dp_qos.property,"dds.builtin_type.string.max_size","2050",true);
        
        DomainParticipant participant = DomainParticipantFactory.get_instance().create_participant(0,
                dp_qos, null, StatusKind.STATUS_MASK_NONE);

        if (participant == null)
        {
            System.err.println("Unable to create domain participant");
            return;
        }
        Publisher publisher = participant.create_publisher(
                DomainParticipant.PUBLISHER_QOS_DEFAULT, null /* listener */,
                StatusKind.STATUS_MASK_NONE);
        Topic topic = participant.create_topic(
                "Event Logging",
                StringTypeSupport.get_type_name(),
                DomainParticipant.TOPIC_QOS_DEFAULT,
                null, // listener
                StatusKind.STATUS_MASK_NONE);
        if (topic == null)
        {
            System.err.println("Unable to create topic.");
            return;
        }
        
        DataWriterQos datawriter_qos = new DataWriterQos();
        publisher.get_default_datawriter_qos(datawriter_qos);
        PropertyQosPolicyHelper.add_property(datawriter_qos.property,"dds.builtin_type.string.alloc_size" ,"2048" ,true);
        StringDataWriter dataWriter =
                (StringDataWriter) participant.create_datawriter(
                        topic,
                        datawriter_qos,
                        null, // listener
                        StatusKind.STATUS_MASK_NONE);
        if (dataWriter == null)
        {
            System.err.println("Unable to create data writer\n");
            return;
        }
        
        for (int i = 0; i < 100; i++) {
            String toWrite = Integer.toHexString(i);
            try {
                dataWriter.write(toWrite, InstanceHandle_t.HANDLE_NIL);
            } catch (RETCODE_TIMEOUT e) {
                e.printStackTrace();
            } catch (RETCODE_ERROR e) {
                e.printStackTrace();
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        System.out.println("Exiting...");
        participant.delete_contained_entities();
        DomainParticipantFactory.get_instance().delete_participant(participant);
    }
}

Note how I've created the qos variable, pre-populated it using a factory call, modified the single parameter you are looking at, and then used the qos variable in the create method for the entity I wanted.  Certain qos -- and certainly any qos that deals with resource management, which max_size and alloc_size certainly do -- have to be configured prior to creation of the entity, as they won't be able to be modified once the resources are configured during the create call.

Others can be modified after creation but before enable (disable auto-enable of entities in the factory if you need to do this).  And finally others can be modified even after enable, during the runtime.  See the documentation.

C:\Users\rip>rtiddsspy -printSample

RTI Data Distribution Service Spy built with DDS version: 5.1.0 (Core: 1.7a.00,
C: 1.7a.00, C++: 1.7a.00)
Copyright 2012 Real-Time Innovations, Inc.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NddsSpy is listening for data, press CTRL+C to stop it.

source_timestamp   Info  Src HostId  topic               type
-----------------  ----  ----------  ------------------  ------------------
1402349231.988987  W +N  C0A83802    Event Logging       DDS::String
1402349240.988987  d +N  C0A83802    Event Logging       DDS::String

value: "9"

1402349241.988987  d +M  C0A83802    Event Logging       DDS::String

value: "a"

1402349242.988987  d +M  C0A83802    Event Logging       DDS::String

value: "b"

 

Offline
Last seen: 4 years 9 months ago
Joined: 05/21/2014
Posts: 46

I am getting this when the program is ran.

RTI Data Distribution Service Spy built with DDS version: 5.1.0 (Core: 1.7a.00, C: 1.7a.00, C++: 1.7a.00)

Copyright 2012 Real-Time Innovations, Inc.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NddsSpy is listening for data, press CTRL+C to stop it.

source_timestamp Info Src HostId topic type 
----------------- ---- ---------- ------------------ ------------------ 
1402405624.575992 R +N 0A0064AE Event Logging DDS::String 
1402406515.185997 W +N 0A0064AE Event Logging DDS::String 
1402406515.186997 W +N 0A0064AE Event Logging DDS::String 
1402406515.265996 d +N 0A0064AE Event Logging DDS::String 
1402406515.265996 W -M 0A0064AE Event Logging DDS::String 
1402406515.266996 W -M 0A0064AE Event Logging DDS::String 
DDS_TIME_INVALID d ?M 0A0064AE Event Logging DDS::String 
Terminate batch job (Y/N)? Terminate batch job (Y/N)?

 

rip
rip's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 04/06/2012
Posts: 324

that tells me it's working.  Use -printSample with rtiddsspy to see what was sent.

Offline
Last seen: 4 years 9 months ago
Joined: 05/21/2014
Posts: 46

It was sending what should be sent. Now if I wanted to set up a datareader, would I have to make any changes to it's qos file as well?

rip
rip's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 04/06/2012
Posts: 324

Yes.  if you don't the writer will be writing 2k strings, and the reader's buffers will only be set up for 1k strings.

If you make changes to Writer QoS, you should immediately look at the Reader's QoS also to see if it must mirror the changes.  In this case yes.