2
votes

I'm using Kepware KEPServerEX 5.15 as my OPC server and OPC DA Automation Wrapper 2.02 in .NET to communicate.

When both my application and KEPServerEX are installed on the same machine I have no issues, everything works as expected but when I move the application to another machine I receive a HRESULT E_FAIL exception on any operations.

I have also installed KEPServerEX on the second machine and the application works when pointed locally. I have also tried running the application from the first machine pointed at the seconds server and still get the HRESULT E_FAIL exeption.

I have also disabled the firewalls on both machines to no effect and enabled Network DTC access and set No Authentication Required in the Local DTC Security Properties.

In summary, when I try and use a remote OPC server the application throws HRESULT E_FAIL.

In the simplest example I am doing the following:

    Dim opcServer As New OPCAutomation.OPCServer
    Dim opcServerEnum As IEnumerable = CType(opcServer.GetOPCServers(hostAddress), IEnumerable)

EDIT: Just found this in the System Event Log:

DCOM got error "2147944122" from the computer 10.24.7.28 when attempting to activate the server: {13486D51-4821-11D2-A494-3CB306C10000}

1
The main reason this error is occurring is because the client is not able to access the OPCENUM.exe on the server due to a fire wall. A lot of settings need to be done to enable this to happen remotely. Read my answer if it still does not solve your problem or if you have any question let me knowVishweshwar Kapse
E_FAIL is merely the teacher's grade for the quality of the error reporting code. Doesn't mean anything more than "Didn't work, don't know why, not my problem". Sure, the event log entry tells you a lot more. Turn big decimal numbers into hex, you'll see it is a wrapped Windows error code. 1722, RPC_S_SERVER_UNAVAILABLE, "The RPC server is unavailable". Not stellar either, but you do now know that the OPC server wasn't installed properly on that machine.Hans Passant
He just mentioned that the opc server was working fine when he had tested the client on the local machine when he shifted the client to remote machine it says RPC is unavailable. This is because the client machine that he is currently testing on does not have DCOM settings on it and has to follow my answer to get it workingVishweshwar Kapse

1 Answers

1
votes

OPC uses DCOM for communicating you need to perform the following steps to solve this issue.

  1. Run the DCOM configuration utility by selecting Run from your Windows Start menu and type dcomcnfg.exe click on OK.

2.Expand Component Services, Computers and RightClick on the MyComputer and select Properties

  1. Select the Tab Default Properties and Check the “Enable Distributed COM on this Computer”. The Default Authentication level should be Connect and the Default Impersonation level should be Identify. NOTE: Provide additional security for reference tracking should be unchecked.

  2. Now select the COM Security Tab and under the Access Permissions section click on the Edit Defaults Button, Click on the Add… Button and add the user name (The newly created user name that is exactly same as that of user name on the server). After adding the New user select it and in the box below check the boxes to enable (Allow) Both Local Access and Remote Access.

  3. For initial test purposes include Everyone in the Grant Access list.

  4. On the machine where the server is add OpcEnum.exe to the firewall exception list

  5. On the client machine's fire wall allow port 135 incoming coneciton

Note: For initial testing disable the firewall on both the server and the client .. :)

  1. Note down the user ID and password of the windows user account under which the opc server is running and create the same user name and account on the remote machine (This is to establish trust between the two computers)

After this you should be able to access the OPC server remotely