Hi everyone,
As the subject says, part of the error message I get is said message. The complete message is following:
[CREATE Participant] DDS_DomainParticipantGlobals_is_operation_legalI:ERROR: This operation is illegal in callback
[CREATE Participant] DDS_DomainParticipantFactory_create_participant_disabledI:INTERNAL ERROR: illegal operation
on_data_available:!Failed to create DomainParticipant
Now that this is out of the way, please allow me to add some story to this, so it makes sense.
I have a GUI, which sends a message to a listener. When the on_data_available of the listener is called, I can receive the samples and do some processing on it. The processing is happening in a callback, I have to mention.
Now, here is where the problem is happening. When I do some processing and leave it as such, then everything is fine. When I try to send the message I received to another endpoint, then I get the above message.
Does anyone have an idea why it fails to create a DomainParticipant? Or is creating a DomainParticipant generally not allowed in the on_data_available function?
I think the first mistake is that in general, no processing should be done in a callback, and specifically no write() operations should be performed. This is stated in our best practices for Listeners:
https://community.rti.com/static/documentation/connext-dds/5.3.0/doc/manuals/connext_dds/html_files/RTI_ConnextDDS_CoreLibraries_UsersManual/Content/UsersManual/BestPracticesListeners.htm
Now, some operations are directly illegal to be done in a callback, you can check the list here.
https://community.rti.com/static/documentation/connext-dds/5.3.0/doc/manuals/connext_dds/html_files/RTI_ConnextDDS_CoreLibraries_UsersManual/Content/UsersManual/Restricted_Operations_in_Listener_Callba.htm
Oh wow, I did not see that. Thank you so much for those links.
Is there a procedure I can after on_data_available is finished and returned somehow? Is there something provided?
I figured out a way to fix the problem. Thank you again for your help!
Hi again,
Using listeners is only one way to access the data in your DataReader, you actually have 3 ways: Polling, Listeners and Waitsets.
See here an article about that in general we recomend the use of waitsets except when you are looking for lower latencies. I think, in general you will like this approach better than the use of Listeners.
Let us know if that helps. Else, let us know your use case so we can think about a solution.