Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPCUAServer with hostname error when subscribed to a discovery server #1024

Closed
nicoloereni opened this issue Jul 8, 2021 · 2 comments
Closed
Labels

Comments

@nicoloereni
Copy link

Hello,
with a Server like:

let server = new OPCUAServer({
            port: 64101,
            hostname: hostname + '/nozomi',
            registerServerMethod: RegisterServerMethod.LDS,
            discoveryServerEndpointUrl: discoveryServerEndpointUrl})
        await server.initialize();

we have a server on:
on opc.tcp://Nicolos-MacBook-Pro-2.local/nozomi:64101

the discovery server when the server start throws:

Error: Required port not given
    at new Service (/Users/nicolo/Documents/opcua_spike/node_modules/bonjour/lib/service.js:18:25)
    at Registry.publish (/Users/nicolo/Documents/opcua_spike/node_modules/bonjour/lib/registry.js:18:17)
    at Bonjour.publish (/Users/nicolo/Documents/opcua_spike/node_modules/bonjour/index.js:16:25)

removing the 'hostname' option everything works fine.

We expect to have opc.tcp://Nicolos-MacBook-Pro-2.local:64101/nozomi instead of
on opc.tcp://Nicolos-MacBook-Pro-2.local/nozomi:64101

Is this a bug or am I doing something wrong?

with a configuration like:

let server = new OPCUAServer({
            hostname: hostname + ':64101/nozomi',
            registerServerMethod: RegisterServerMethod.LDS,
            discoveryServerEndpointUrl: discoveryServerEndpointUrl})
        await server.initialize();

the subscription to the discovery server works, but the endpoint is:
on opc.tcp://Nicolos-MacBook-Pro-2.local:64101/nozomi:26543

Many thanks

@stale
Copy link

stale bot commented Sep 21, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 21, 2022
@erossignon
Copy link
Member

erossignon commented May 7, 2023

hostname should only be hostname. / is a invalid character in hostname.

I guess you want to use ressourcePath instead

import { hostname as getHostname } from "os";

const hostname = getHostname();

const server = new OPCUAServer({
      port: 64101,
      hostname,
      resourcePath: '/nozomi',
      registerServerMethod: RegisterServerMethod.LDS,
      discoveryServerEndpointUrl
});
await server.start();
console.log(server.getEndpointUrl());
await server.shutdown();

will produce the endpointUrl opc.tcp://Nicolos-MacBook-Pro-2.local:64101/nozomi

erossignon added a commit that referenced this issue May 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants