Linux demo server/client can't connect.

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

Moderator: uasdkcpp

Post Reply
RobKey
Full Member
Full Member
Posts: 6
Joined: 24 Jul 2013, 14:33

Linux demo server/client can't connect.

Post by RobKey »

Hello,

I'm playing with the evaluation version of the C++ SDK.
On windows the client and server work fine as far as I can tell, but on Linux client can't discover the server (client_cpp_sdk and uademoserver binaries running on the same virtual box).

When discovering I get the following error on the client:

Code: Select all

****************************************************************
** Call findServers and getEndpoints for each Server
** Error: UaDiscovery::findServers failed [ret=0x80050000] *********
Why this may be happening?
Is there anything I need to configure on the linux box to make the discovery work?

How I can connect to a server via IP?

I apologize if those questions were answered on the forum but the forum search function is not allowing to search for any common words (network, linux, discovery... ) making it utterly useless.

Best regards,

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

Re: Linux demo server/client can't connect.

Post by Support Team »

Assuming that you have ensured that the server is really up and running. Further more assuming that you call to the correct URL including correct port number, the error you experience very likely has to do with resolution of hostname. The FindServer uses the URL which must be properly relolved in order to work correclty. Therefore passing URL with name or with IP will make a difference when having no domain name server in place. On Linux you must make sure that the names in etc/host are set correclty.

Best Regards
Support Team

RobKey
Full Member
Full Member
Posts: 6
Joined: 24 Jul 2013, 14:33

Re: Linux demo server/client can't connect.

Post by RobKey »

the server is running and listening on a hostname:

Code: Select all

hvpd@localhost:~/ua_sdk/bin$ ./uademoserver
Initializing keyboard.
***************************************************
 Server opened endpoints for following URLs:
     opc.tcp://test_domain:4841
***************************************************
the hostname is resolvable:

Code: Select all

hvpd@localhost:~/ua_sdk/bin$ ping -c 1 test_domain
PING test_domain (192.168.1.76) 56(84) bytes of data.
64 bytes from test_domain (192.168.1.76): icmp_req=1 ttl=64 time=0.026 ms

--- test_domain ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.026/0.026/0.026/0.000 
But the error still presists:

Code: Select all

****************************************************************
** Call findServers and getEndpoints for each Server
** Error: UaDiscovery::findServers failed [ret=0x80050000] *********
If I use lesson 2 client code and hardcode url to "opc.tcp://test_domain:4841" then connection itself works:

Code: Select all

****************************************************************
** Try to connect to selected server
-- Event connectionStatusChanged ----------------------
clientConnectionId 0 
serverStatus 1 
-------------------------------------------------------
** Connected to Server opc.tcp://test_domain:4841 ****
****************************************************************
but the discovery stil doesn't.

I would expect that the discovery will find at least server running on the same machine using localhost and 127.0.0.1 ip but that fails as well :(

Any suggestions how to make the discovery to work on linux?
Best regards,

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

Re: Linux demo server/client can't connect.

Post by Support Team »

The UA Stack delivered by us is able to use IPv4 AND IPv6 addresses. There is prefered use of V6 in case available on both partners. On Linux you could have both configured in etc/host (default) BUT only one actually active and running. You should check your etc/host file if you have 2 entries for "localhost" (one for IPv4 and one for IPv6), if your Linux has IPv6 disabled, you should comment out the IPv6 entry, just to avoid confusion. To check if IPv6 is disabled you should call "ifconfig" and verify if only v4 addresses are returend or if you have v6 addresses as well.

After commenting out the v6 entry "::0 localhost" the linux machine will resolve the "localhost" always to 127.0.0.1. Having done this you should try to discover and to connect again. Now the Server will bind "localhost:4841" to an IPv4, because IPv6 is deactivated on the machine anyway, and the Client will resolve "localhost:4841" to an IPv4 address, because you have commented out the v6 in etc/host. At least the connect should work now. The discovery might not, but for a different reason.

The discovery might not work because, even when configured differently in the client side ini file, the client falls back to hardcoded value e.g. when not being able to read/find it's own ini file. The default is "localhost:4840", but your server runs on "4841". The fall back to hardcoded URL can be changed in the client example code.

Best Regards
Support Team

Post Reply