node-opc-da icon indicating copy to clipboard operation
node-opc-da copied to clipboard

session.getStub is not a function

Open Husenjon opened this issue 3 years ago • 2 comments

UnhandledPromiseRejectionWarning: TypeError: session.getStub is not a function

Husenjon avatar Mar 15 '21 08:03 Husenjon

Also getting this issue.

adonnelly759 avatar May 03 '22 09:05 adonnelly759

I've managed to pass that error using the below code, but also this code doesn't work..

const DCOM = require('node-dcom');
const OPC = require('node-opc-da');

const main = async () => {
  // creates a COM Session from a domain, an username, and a password
  let comSession = new DCOM.Session();
  comSession = comSession.createSession(domain, username, password);

  // sets a global timeout for connections related to this session
  comSession.setGlobalSocketTimeout(timeout);

  // create a COM Server from a classid, an IP address and the previously created session
  let clsid = new DCOM.Clsid(ClassID);
  let comServer = new DCOM.ComServer(clsid, address, comSession);

  // star the COM Server
  await comServer.init();

  /* from the COM Server, we create a instance we'll use to create every other COM related object */
  let comObject = await comServer.createInstance();

  // with the comObjet created, we create an OPC Server object and call init()
  let opcServer = new OPC.OPCServer();
  await opcServer.init(comObject);

  let opcBrowser = await opcServer.getBrowser();
  let items = await opcBrowser.browseAllFlat();

  console.log({items});
}

iosifnicolae2 avatar Aug 14 '23 13:08 iosifnicolae2