async function startMultiHeadServer() {

    const server_options: OPCUAServerOptions = {
        isAuditing: false,
        nodeset_filename: [
            nodesets.standard
        ],
        serverInfo: {
            applicationName: { text: "Mini NodeOPCUA Server", locale: "en" },
            applicationUri: makeApplicationUrn("%FQDN%", "MiniNodeOPCUA-Server"),
            productUri: "Mini NodeOPCUA-Server"
        },

        // default endpoint
        allowAnonymous: false,
        alternateHostname: ["MyHostname1"],
        port: port1,
        securityModes: [MessageSecurityMode.None],
        securityPolicies: [SecurityPolicy.None],

        // alternate endpoint
        alternateEndpoints: [
            {
                allowAnonymous: false,
                alternateHostname: ["1.2.3.4"],
                port: port2,
                securityModes: [MessageSecurityMode.SignAndEncrypt],
                securityPolicies: [SecurityPolicy.Basic256Sha256]
            }
        ]
    };

    server = new OPCUAServer(server_options);

    server.on("post_initialize", () => {/**/
    });

    console.log(chalk.yellow("  server PID          :"), process.pid);

    try {
        await server.start();
    } catch (err) {
        console.log(" Server failed to start ... exiting => err:", err.message);
        return;
    }

}
async function startServer() {

    const server_options: OPCUAServerOptions = {

        port: port1,

        nodeset_filename: [
            nodesets.standard
        ],

        serverInfo: {
            applicationUri: makeApplicationUrn("%FQDN%", "MiniNodeOPCUA-Server"),
            productUri: "Mini NodeOPCUA-Server",

            applicationName: { text: "Mini NodeOPCUA Server", locale: "en" }

        },

        alternateHostname: ["MyHostname1", "MyHostname2"],

        isAuditing: false
    };

    server = new OPCUAServer(server_options);

    server.on("post_initialize", () => {/**/
    });

    console.log(chalk.yellow("  server PID          :"), process.pid);

    try {
        await server.start();
    } catch (err) {
        console.log(" Server failed to start ... exiting => err:", err.message);
        return;
    }

    for (const endpoint of server.endpoints) {
        const endpointUrl = endpoint.endpointDescriptions()[0].endpointUrl!;
        console.log(chalk.yellow("  server on port1      :"), endpoint.port.toString());
        console.log(chalk.yellow("  endpointUrl1         :"), chalk.cyan(endpointUrl));
    }

}
Exemplo n.º 3
0
const server_options = {

    certificateFile: server_certificate_file,
    privateKeyFile: server_certificate_privatekey_file,

    port,

    maxAllowedSessionNumber: 2,
    maxConnectionsPerEndpoint: 2,

    nodeset_filename: [
        get_mini_nodeset_filename()
    ],

    serverInfo: {
        applicationUri: makeApplicationUrn("%FQDN%", "MiniNodeOPCUA-Server"),
        productUri: "Mini NodeOPCUA-Server",

        applicationName: { text: "Mini NodeOPCUA Server", locale: "en" },

        gatewayServerUri: null,

        discoveryProfileUri: null,

        discoveryUrls: []
    },

    buildInfo: {
        buildNumber: "1234"
    },