3

I am trying to connect to a server with node-opcua, but having a bit of trouble.

Connecting to the same server with the Prosys OPC UA Browser software works just fine.

const client = OPCUAClient.create({
    endpointMustExist: false,
    securityMode: MessageSecurityMode.SignAndEncrypt,
    securityPolicy: SecurityPolicy.Basic256Sha256
});

await client.connect(endpointUrl);

const session = await client.createSession({
        userName: data.userName,
        password: data.password,

    },
    function(err) {
        console.log(err)
    }
);

It connects, but I am getting the error: 'Error: Invalid channel' and it immediatley disconnects.

What does this mean?

Solsiden
  • 673
  • 1
  • 7
  • 22

1 Answers1

0

For some reason client.createSession() doesn't return anything if I create with userName and password (2.71.0).

My code failed because I disconnect the connection if the session variable is null or undefined.

Worked around it:

client.createSession({
        userName: data.userName,
        password: data.password,
    },
    function(err, _session) {
        if (err) {
            console.log(err)
        } else {
            onSessionEstablished(_session)
        }
    }
);

function onSessionEstablished(session)
{
    // Do things with session
}
Solsiden
  • 673
  • 1
  • 7
  • 22