OPC UA PubSub Traps And Pitfalls

From OPC Labs Knowledge Base
Revision as of 17:21, 5 February 2020 by User (talk | contribs)
Error "Unable to activate the adapter (...). Return code: -8"
On Linux, elevated privileges are needed in order to send raw Ethernet packets. Run your program with sudo to resolve this issue. On Windows, depending on how the driver was installed, elevated privileges might be needed as well.
Error "Unable to load shared library 'libpcap' or one of its dependencies. ..."
If you are on Ubuntu 18: Libpcap is "preinstalled", but SharpPcap won't find it. There are various ways how to resolve it. One of them is to create a copy of symlink /user/lib/x86_64-linux-gnu/libpcap.so.0.8 to symlink libpcap.so in the same directory.
My subscription filter matches the publisher configuration, but messages are still being filtered out.
Make sure that you only put information to the filter that is actually contained in the messages. For example, you may have specified a concrete dataset writer ID, based on the publisher configuration, in your filter. But, in UADP fixed profile, the dataset writer ID is not actually transmitted in the network messages, and therefore you must use zero for the dataset writer ID in your filter.
Subscriber does not receive anything, even when no filter is specified - but I am sure the publisher works.
Check that you are publishing and subscribing on the intended network interfaces. On computers with multiple interfaces, which is now common, a default interface is chosen by the software when no interface is specified, and it may commonly be a wrong choice. In tools like OpcCmd or UADemoSubscriber, use the -ConnectionNetworkInterface (-cni) option. In subscriber code, set the InterfaceName property of UAPubSubConnectionDescriptor.ResourceAddress.
Subscriber does not receive anything, when on the same host as the publisher.
This happens with some network adapters. You can install and use a loopback adapter to make it work. On Windows 10, run Add Hardware Wizard (hdwwiz.exe), tell it that you want to select the hardware manually from a list, and from Network Adapters, select Microsoft -> Microsoft KM-TEST Loopback Adapter. Be careful - adding a new adapter without further configuration may have other, sometimes unforeseen, consequences - such as that traffic might get routed into the adapter when you do not want it. It is recommended that you disable the adapter when not in use for your tests.
There is a delay after the connection is established, before the dataset messages start coming.
This may be due to use of delta frames by the publisher. QuickOPC does not deliver incomplete datasets (from the delta frames) to you. It therefore needs to wait for the first key frame.

How to obtain network interface names

On Windows, we recommend using the following command to obtain a list of available network interfaces:
  netsh interface ip show interfaces

Other related commands are:

netsh interface show interface
ipconfig |findstr "adapter"
netsh mbn show interfaces
wmic nic get NetConnectionID

On Linux, we recommend using the following command to obtain a list of available network interfaces:
  netstat -i

Other related commands are:

ip link show
nmcli device status
nmcli connection show
ifconfig -a