PubSub example

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
MortenSchou
Full Member
Full Member
Posts: 9
Joined: 14 Feb 2018, 10:49

PubSub example

Post by MortenSchou »

Hi Support Team,

Great news PubSub is now supported in .NET based OPC UA SDK.

However, I have searched and browsed the examples but have been unable to see through how to configure what is published from a server and how to connect to an MQTT broker.

Could you please provide a working example of this or guide me to where to look in the examples provided with the SDK?


Best regards,

Morten Schou

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: PubSub example

Post by Support Team »

Hi,

you find an explanation, how to configure PubSub in the Demo Server documentation:
https://documentation.unified-automation.com/uasdknet/4.0.0/html/L3ServerTuDemoServerPubSub.html

we currently only support the configuration via the PubSubConfigurationType (https://reference.opcfoundation.org/Core/Part14/v105/docs/9.1.3.7) in the address space. With that, a configuration tool, for example the UaExpert, can read, write and extend the server's PubSub configuration. If you require a different type of configuration, e.g. by code, please tell us more about your ideas or use case. We currently have not found a compelling reason for a different configuration mechanism.
Best regards
Unified Automation Support Team

MortenSchou
Full Member
Full Member
Posts: 9
Joined: 14 Feb 2018, 10:49

Re: PubSub example

Post by MortenSchou »

Thank you very much for your reply.

I will have a look at the example and come back to you should we come up with an alternative use case.

MortenSchou
Full Member
Full Member
Posts: 9
Joined: 14 Feb 2018, 10:49

Re: PubSub example

Post by MortenSchou »

Hi Support Team,

We have now successfully accomplished to make changes to our current OPC UA server and configure it to publish data on MQTT.

However, this is done in a similar way to the Demo Server where configuration is done though a OPC UA client (UaExpert) connected to the server.
Currently, we have automated configuration of the address space of our server, based on a proprietary configuration file, through code in the server.
This enables us to upload the configuration file to the server on site to change its configuration.

We would really like to configure PubSub similarly to avoid having a client to connect to the server for (re-)configuration.

Is this currently possible through the address space of the server or is this the kind of use case you have decided not to support (yet)?

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: PubSub example

Post by Support Team »

Hi,

thank you very much for your feedback. First of all, preventing an external client to change the configuration is pretty easy. You can simply set the Executable attribute of the ConfigureAndUpdate method to "false".

Code: Select all

InternalClient.WriteAttribute(DefaultRequestContext, MethodIds.PublishSubscribe_PubSubConfiguration_CloseAndUpdate, Attributes.Executable, false);
Remains the problem that you cannot change the configuration by code (yet). There is a possible workaround, albeit a hacky one. When the PubSub system is started, it will read the previously persisted configuration from file if present. The configuration file is in the standardized UABinaryFileDataType format. This can as well be generated by the UaExpert or also be generated by code. On shutdown this file will be replaced by the current configuration, which should be identical, though.

How this can be solved by code? One way would be an InternalPubSubConfigurator similar to the internal client. The challenge is that the configuration via the PubSubConfigurationType contains a transaction mechanism. The internal configurator should not interfere the transaction of the external client and vice-versa.

Another way would be to have a property on the ApplicationInstance to pass a starting configuration. There, we would not run into the transaction difficulties but to change the configuration (by code) the server would need to be restarted. Here is challenging, that the ApplicationInstance is usually configured before the server is starting, so you would need to know NodeIds of nodes that do not exist at that point.

Now that we know that there is interest in this feature, it is worthwhile to dig deeper into it.
Please create a support ticket via the support form:
https://webdav.unifiedautomation.com/support/support_form.html
Best regards
Unified Automation Support Team

Post Reply