Node-opcua server

I am trying to use node-opcua with a simple scene and comparing with the codesys example. No luck so far.
Has anyone tried this? I can get FactoryIO to connect with my server but not receive any data (at entry, at exit in my case).

1 Like

had omitted the setter… working fragment below

    let atEntry = false;
  componentOf: device,
  nodeId: "s=atEntry",
  browseName: "atEntry",
  dataType: "Boolean",
  value: {
    get: function() {return new opcua.Variant({dataType: opcua.DataType.Boolean, value: atEntry});},
    set: function(variant) {atEntry = variant.value; return opcua.StatusCodes.Good;}

Nice one. So, this means you can now control the scene via Node.js?

1 Like

I am still just trying to read but in theory yes. At the moment I see session issues though. Below is a screenshot of the server and below the commander console (separate repo under node-opcua)
At the first occurrence of session transfer, FactoryIO dialog popped up. I had to manually refresh on FactoryIO. At the second occurrence, FactoryIO did not throw a dialog and continued although the data is not being transmitted.

1 Like

after I put the cursor in the OPC Server config and simply hit enter, data transmission resumes


Okay, so does this work stable?

I just started with this but so far, comparing with Modbus, no. I will post separately my solution with a Node Modbus library which handles better network issues. That is not to say node-opcua cannot - more that I need to put more time into it. FactoryIO may also have a better support for Modbus?


@jdevoo node-opcua was one of the tools we have used to test the OPC UA driver during development. The results were quite good and we were impressed with how easy it is to develop a custom OPC UA server using javascript.

In my opinion, OPC is way to complex - maybe more than it should be. Modbus is simpler but also very limited. Whenever possible, I choose Modbus over OPC.

I’m attaching to this post a modified version of the official sample server which includes two boolean variables (input/output). Maybe it can serve as a starting point for anyone waiting to explore node-opcua.

GIF 06-07-2020 16-35-49


  1. Extract the zip archive and run: npm install
  2. run: node sample_server.js
  3. Open the included scene (node.js-opcua.factoryio) in FIO and set the correct server url in the OPC Configuration panel (find it in 2). (62.9 KB)


Thank you very much @brunovgr, great help as always!

And thanks to @jdevoo for taking a dive into this. I will test this myself to see if I get it running.

1 Like