Cannot connect with hostname on a second computer

Questions regarding the use of the UaExpert.

Moderator: uaexpert

Post Reply
DavidBo
Jr. Member
Jr. Member
Posts: 4
Joined: 23 Nov 2021, 17:54

Cannot connect with hostname on a second computer

Post by DavidBo »

I have 2 Windows 10 clients and the server is a Linux Debian server
With the first Windows Computer I get
14:15:20.050 | Server Node | OPCUAServer@harmonia-05 | Connection status of server 'OPCUAServer@harmonia-05' changed to 'NewSessionCreated'.
14:15:20.051 | Server Node | OPCUAServer@harmonia-05 | Namespace table changed, mapping old to new namespace indices
14:15:20.051 | Server Node | OPCUAServer@harmonia-05 | Connection status of server 'OPCUAServer@harmonia-05' changed to 'Connected'.

With the second it fails
7:41:43.393 | Server Node | OPCUAServer@harmonia-05 | Endpoint: 'opc.tcp://harmonia-05:4840'
17:41:43.393 | Server Node | OPCUAServer@harmonia-05 | Security policy: 'http://opcfoundation.org/UA/SecurityPolicy#None'
17:41:43.393 | Server Node | OPCUAServer@harmonia-05 | ApplicationUri: 'urn:harmonia-05:3S%20-%20Smart%20Software%20Solutions%20GmbH:CODESYS%20Control%20for%20Raspberry%20Pi%20SL:OPCUA:Server'
17:41:43.393 | Server Node | OPCUAServer@harmonia-05 | Used UserTokenType: Anonymous
17:41:43.393 | Server Node | OPCUAServer@harmonia-05 | The server returned no certificate, all certificate checks will be skipped.
17:41:45.685 | Server Node | OPCUAServer@harmonia-05 | Error 'BadHostUnknown' was returned during OpenSecureChannel
17:41:45.686 | Server Node | OPCUAServer@harmonia-05 | Connection status of server 'OPCUAServer@harmonia-05' changed to 'Disconnected'.

I can connect by using the IP address and I can do a DNS lookup. The server also has Web server and I have no problems with accessing the webserver with a browser. As far as I can tell the firewall on the client seems to be open for OPC, but I am not a Windows 10 firewall expert.
What can be wrong ?

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

Re: Cannot connect with hostname on a second computer

Post by Support Team »

Hi,

obviously the hostmal can not be resolved.
What is returned when you "ping" on the hostname? Is there a difference when comparing the "ping" result of the two comuters?

It may be the case that one retunring an IP-v4 address and the other an IP-v6 address. The OPC UA stacks have preferences of either one or both. You may force the Windows (etc/host/) to get name resolution straight in case DNS is not working.
Best regards
Unified Automation Support Team

DavidBo
Jr. Member
Jr. Member
Posts: 4
Joined: 23 Nov 2021, 17:54

Re: Cannot connect with hostname on a second computer

Post by DavidBo »

Hi
I have now enabled more trace and logging in my UaExpert client version 1.6.1.424
First the log says:

| Server Node | OPCUAServer@sipylus | Endpoint: 'opc.tcp://sipylus:4840'
| Server Node | OPCUAServer@sipylus | Security policy: 'http://opcfoundation.org/UA/SecurityPolicy#None'
| Server Node | OPCUAServer@sipylus | ApplicationUri: 'urn:sipylus:3S%20-%20Smart%20Software%20Solutions%20GmbH:CODESYS%20Control%20for%20Raspberry%20Pi%20SL:OPCUA:Server'
| Server Node | OPCUAServer@sipylus | Used UserTokenType: Anonymous
| Server Node | OPCUAServer@sipylus | The server returned no certificate, all certificate checks will be skipped.
| General | | [uastack] OpcUa_P_RawSocket_InetAddr: getaddrinfo failed with 11001.
| General | | [uastack] OpcUa_P_ParseUrl: OpcUa_P_RawSocket_InetAddr reports error 0xA0060000.
| Server Node | OPCUAServer@sipylus | Error 'BadHostUnknown' was returned during OpenSecureChannel
| Server Node | OPCUAServer@sipylus | Connection status of server 'OPCUAServer@sipylus' changed to 'Disconnected'.

In my trace file I have:

|6|4244* [uastack] OpcUa_Channel_BeginConnect: Channel 04E23550, URL opc.tcp://sipylus:4840
|6|4244* [uastack] OpcUa_SecureConnection_Connect: sync connect for connection 071136F0
|6|4244* [uastack] OpcUa_P_ParseUrl: Parsing "opc.tcp://sipylus:4840".
|6|4244* [uastack] OpcUa_P_ParseUrl: Testing for IPv4 address or hostname.
|6|4244* [uastack] OpcUa_P_ParseUrl: Non-numeric name detected.
|6|4244* [uastack] OpcUa_P_ParseUrl: Trying to resolve host "sipylus" port "4840" to address family 0.
12:04:13.244Z|4|3580* [uastack] NetworkThread: Message Loop started...
12:04:13.259Z|6|4244* [uastack] OpcUa_P_ParseUrl: 0: Resolved to IPv4 address family.
12:04:13.259Z|6|4244* [uastack] OpcUa_P_ParseUrl: 0: Numeric representation of resolved address is 192.168.1.101.
12:04:13.259Z|6|4244* [uastack] OpcUa_P_ParseUrl: 1: Resolved to IPv6 address family.
12:04:13.259Z|6|4244* [uastack] OpcUa_P_ParseUrl: 1: Numeric representation of resolved address is fe80::22dd:faac:cfa5:a441%6.
12:04:13.259Z|6|4244* [uastack] OpcUa_P_Socket_Delete: Closing socket 07116128!

...
...
12:04:13.306Z|6|213C* [uastack] OpcUa_AsyncCallState_Create: 04340728
...
12:04:13.306Z|6|213C* [uastack] OpcUa_Channel_BeginConnect: Channel 04E23860, URL opc.tcp://sipylus:4840

...
12:04:13.306Z|4|213C* [uastack] OpcUa_TcpConnection_Delete: Communication stopped.
...
12:04:13.306Z|6|213C* [uastack] OpcUa_SecureConnection_CancelOpenRequests: Canceling 0 open requests at connection 07296958.
12:04:13.306Z|6|213C* [uastack] OpcUa_SecureConnection_Connect: sync connect for connection 07160880
12:04:13.306Z|4|2C80* [uastack] NetworkThread: Message Loop started...
12:04:13.306Z|6|213C* [uastack] OpcUa_P_ParseUrl: Parsing "opc.tcp://sipylus:4840".
12:04:13.306Z|6|213C* [uastack] OpcUa_P_ParseUrl: Testing for IPv4 address or hostname.
12:04:13.306Z|6|213C* [uastack] OpcUa_P_ParseUrl: Non-numeric name detected.
12:04:13.306Z|6|213C* [uastack] OpcUa_P_ParseUrl: Trying to resolve host "sipylus" port "4840" to address family 0.
12:04:15.574Z|2|213C* [uastack] OpcUa_P_RawSocket_InetAddr: getaddrinfo failed with 11001.
12:04:15.574Z|2|213C* [uastack] OpcUa_P_ParseUrl: OpcUa_P_RawSocket_InetAddr reports error 0xA0060000.
12:04:15.574Z|6|213C* [uastack] OpcUa_AsyncCallState_Delete: 04340728

As DNS server I use dnsmasq on a Raspberry PI.
From the beginning in my trace file it is obvious that the IP addresses can be found by UaExpert.
I have no problems doing a ping hostname on any computer
However, I know that my DHCP server dnsmasq only configured to give an ipV4 address. So the problem might have something to do with ipV6. How can I configure UaExpert only to use ipV4?

DavidBo
Jr. Member
Jr. Member
Posts: 4
Joined: 23 Nov 2021, 17:54

Re: Cannot connect with hostname on a second computer

Post by DavidBo »

Hi
I have now successfully a combined DHCP/DNS server with dnsmasq on a raspberry pi working with ip4 and ipv6 as well shown here from Windows 10:
C:\Users\DavidBo>ping sipylus

Pinging sipylus.local [192.168.1.101] with 32 bytes of data:
Reply from 192.168.1.101: bytes=32 time<1ms TTL=64
Reply from 192.168.1.101: bytes=32 time=1ms TTL=64
Reply from 192.168.1.101: bytes=32 time=1ms TTL=64
Reply from 192.168.1.101: bytes=32 time=1ms TTL=64

Ping statistics for 192.168.1.101:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms

C:\Users\DavidBO>ping sipylus -6

Pinging sipylus.local [fd51:42f8:caae:d92e::12b] with 32 bytes of data:
Reply from fd51:42f8:caae:d92e::12b: time=1ms
Reply from fd51:42f8:caae:d92e::12b: time=1ms
Reply from fd51:42f8:caae:d92e::12b: time=1ms
Reply from fd51:42f8:caae:d92e::12b: time=1ms

Ping statistics for fd51:42f8:caae:d92e::12b:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 1ms, Average = 1ms

C:\Users\DavidBo>nslookup sipylus
DNS request timed out.
timeout was 2 seconds.
Server: UnKnown
Address: fd51:42f8:caae:d92e::ff

Name: sipylus
Addresses: fd51:42f8:caae:d92e::12b
192.168.1.101

Reverse lookup do also work, but I still get the error from UaExpert

DavidBo
Jr. Member
Jr. Member
Posts: 4
Joined: 23 Nov 2021, 17:54

Re: Cannot connect with hostname on a second computer

Post by DavidBo »

I have figured out that if I create 2 servers one with an ip address and another one with opc.tcp://sipylus:4840 and I do:
1)connect with the server with ip address
2) disconnect
3) connect with the server sipylus

Now it works fine, so it seems that UaExpert resolves hostnames in some local cache before it connects to the server, but again it does not solve my problem.

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

Re: Cannot connect with hostname on a second computer

Post by Support Team »

Hi,

no the UaExpert is not caching anything. the errror in the trace file is very clear coming from the Microsoft socket API.

RawSocket_InetAddr: getaddrinfo failed with 11001

There are plenty issues described, and there is an error cache which may cause issues when previous calls to InetAddr have caused errors. However, if your system and infrastructure is configured correctly, there should be no errors.
Best regards
Unified Automation Support Team

Post Reply