Search code examples
node-opcua

In nodejs using opcua.OPCUAClient how to connect to a Matrikon OPC Simulation server


I have used the code in https://github.com/node-opcua/node-opcua/blob/master/documentation/creating_a_client.md to create a opcclient to read from the sample_server. That worked OK. Now I want to connect to a Matrikon OPC simulation server. So in the node sample_client ,I changed the

var endpointUrl = "opc.tcp://" + require("os").hostname() + ":8080/Matrikon.OPC.Simulation.1";

In the MatrikonOPC Explorer, on the left tab I see

Localhost '\\compname'
     Matrikon.OPC.Simulation.1
        Group0

on clicking Group0 in the right pane, I have a tag Random.Int1 and the value is continuously changing. In the server Info pane,it says server stare as running.

When I run the node sample_client, it gives no output..it doesn't even give the

"cannot connect to endpoint"

error. It seems like it is stuck in the foll line

client.connect(endpointUrl,function (err) {

Would anybody know why and how I hve to construct the endpoint url.


Solution

  • It seems that the server your trying to connect to is an old OPC classic server (using the DCOM from Microsoft as a communication layer) and not an OPC.UA server (using the new unified architecture standard on TCP). This is why Matrikon.OPC.Explorer can connect to it. There is no easy way to connect OPC <=> OPC.UA directly as the two technologies are different unless you use a special bridging software. see also Difference Between OPC UA and OPC DA? for more info about Classic OPC vs OPC.UA