如何在不知道端口的情况下通过node.js连接到“ In-Sight OPC服务器”?

问题描述 投票:0回答:1

这就是我试图创造的东西,这对我来说是全新的。我希望有人可以帮助我。

//this is the part I cannot figure out, maby anyone knows a tool how to find this port
const endpointUrl = "opc.tcp://145.49.49.3:???";

const opcua = require("node-opcua");
const AttributeIds = opcua.AttributeIds;
const OPCUAClient = opcua.OPCUAClient;

(async function main(){

    const client = new OPCUAClient({});
    await client.connect(endpointUrl);
    const session = await client.createSession({userName: "admin", password: ""});

    const dataValue = await session.read({nodeId: "ns=1;s=AcquisitionCount",attributeId: AttributeIds.Value});
    console.log(`Count is ${dataValue.value.value.toPrecision(3)}°C.`);

    await client.closeSession(session,true);
    await client.disconnect();

})();
javascript node.js opc-ua
1个回答
0
投票

默认端口是4840,但是您将不得不通过一种或另一种方式来解决它。

通常,您要连接的服务器在某些地方的某些配置中包含完整的端点URL,端口,文档或列出的端口。

© www.soinside.com 2019 - 2024. All rights reserved.