Access an OPC server remotely using OPCDA.NET tools

I am developing an OPC client in Windows C #. I developed the code and read the OPC Elements on a sample, as well as event-based (OnDataChange). When I work with the local machine, then my code works fine both with sampling and with OnDataChange, but when I try to read data from a remote OPC server, Sampling works fine, but I can not get event data based on the process. I can connect to the OPC server, but when I add a subscription to then I get an error.

HRESULT: 0x80040202.

group1.DataChanged += new DataChangeEventHandler(this.DataChangeHandler); group1.AdviseIOPCDataCallback();//exception HRESULT : 0x80040202. 

The OPC server is connected, and then register the group, but I got an exception while reading the data.

+4
source share
3 answers

Usually the problem is that when using Advise() server will connect DCOM to the client (standard DCOM connection points). The client must be configured correctly for this to happen (that is, the correct security settings that allow the server to execute code on the client).

You should read this page: http://www.softwaretoolbox.com/xpsp2/ , it contains many recommendations on how to properly configure DCOM to use OPC. There are a lot of security issues here. The Software Toolbox website has a lot of great information (and video too). If you still have problems with its operation, I recommend investing in an OPC tunneling product that will allow you to do remote OPC without jumping over all DCOM loops.

You do not need to use OPCDA.NET for the same problem. You can use any OPC client and work with your remote server first, and then focus on figuring out how to connect to OPCDA.NET. I recommend OPC Quick Client (comes with Software Toolbox TOP Server demo).

+3
source

The problem you are really facing is with the callback. In other words, this is not a call that does not suit you, it is a callback from the OPC server (which indicates triggers). This error is usually caused by user authentication problems (i.e., user accounts do not match on both computers). Verify the OPC server user account on the remote computer. If it does not exist on your local computer, you have encountered a problem!

There is an automated application that will help you sort out your problem. I recommend downloading OPC Expert (Google it). This is a free application, does not require installation and does not change the Windows registry. It has saved me many times. In addition, the provider (OPCTI) is extremely useful, so check them out.

+1
source

This problem is due to the fact that when connecting to the server, you can use the first connection function, which server.connect();

Try instead:

 server.connect(new Opc.ConnectData(new System.Net.NetworkCredential())); 

This works for me. Hope this helps :)

0
source

All Articles