URL Settings for Current IP Address and Running Changes

Questions regarding the use of the C++ SDK for Server or Client development or integration into customer products ...

Moderator: uasdkcpp

Post Reply
myoensky
Full Member
Full Member
Posts: 7
Joined: 06 Jun 2013, 05:51

URL Settings for Current IP Address and Running Changes

Post by myoensky »

I am currently using the ServerConfig.ini file to configure my OPC UA server. I am trying to figure out how to start the server with the correct IP address if I do not know the IP address ahead of time (when I modify the ServerConfig.ini file.) I also am trying to find out how to handle a change of IP address after the server is running.

Right now I have:
UaEndpoint/Url_1=opc.tcp://10.10.0.8:4841
DiscoveryRegistration/Url_1=opc.tcp://10.10.0.8
and this seems to work well as long as that is the only IP address I need, but what I need to do is be able to use whatever IP address is set to the port...

I tried this:
UaEndpoint/Url_1=opc.tcp://localhost:4841
DiscoveryRegistration/Url_1=opc.tcp://localhost
and this doesn't work for me. It correctly browses for discovery on another computer, but that discovery sends the other computer a URL with localhost in it, which makes it not able to connect. When this happens I get the following error in UaExpert:
Discovery GetEndpoints on opc.tcp://localhost:4841 failed (BadCommunicationError)
But I was able to successfully 'discover' my OPC UA server with the target's IP address of 10.10.0.8. This part makes sense to me because when the other computer tries to connect to localhost:4841, it isn't running an OPC UA server, the remote target is.

How should I set this up so that it correctly binds to the current IP address on my system?

I also will need to be able to modify the IP address after the server is started. How can this be handled?

Thank you for your help!

User avatar
Support Team
Hero Member
Hero Member
Posts: 3079
Joined: 18 Mar 2011, 15:09

Re: URL Settings for Current IP Address and Running Changes

Post by Support Team »

In the configuration of the server you have different options.
1) use the hostname >> implicitely bind to all IP Adresses on the machine
2) use the a specific IP >> just bind to this IP only
3) use localhost >> bind to 127.0.0.1, server will only be available locally/internal

The LDS server is intended to represent the "local" UA servers only (that is why it is called "Local Discovery Server"). Hence the target address where to register will be most likely "opc.tcp:\\localhost:4840" as your server most likely want to register itself at his LDS residing on the same machine. Now the server's URL that gets registered, is the one you have specified, unfortunately "localhost" is not a good idea, as giving that to an outside client makes no sense. Typically you would register "opc.tcp:\\computername:4841" and when the LDS gives this to the outside client, the client should be able to find the correct machine (this of course requires a proper network infrastructure including DNS for name resolution).

Best Regards
Support Team

Post Reply