Hi,
This error could be happening because the OPC UA server is returning a discovery URL or endpoint URL containing a hostname that can't be resolved by the computer. You can verify this by capturing the OPC UA data packets in an application like Wireshark and viewing the "FindServersResponse" or "GetEndPointsResponse" OPC UA packets.
For e.g. here are the sequence of steps that occur internally when executing the following command:
uaClient = opcua("192.168.100.10",4840)
- Query Discovery URL: In this step the OPC UA client will send the "FindServersRequest" packet to 192.168.100.10 and the server at that IP will respond with a "FindServersResponse" containing the server's discovery URL.
- Get Endpoints: The client then sends a "GetEndpointsRequest" to the discovery URL received in the previous step. The server should ideally return a "GetEndpointsResponse" containing the final end point URL that the client can connect to.
So, in either step #1 or #2 above, the discovery or endpoint URL may contain a hostname that cannot be resolved by the computer on which the client runs. (e.g. opc.tcp://raspberrypi:4840).
As per the OPC UA Foundation:
"A Server may have multiple HostNames. For this reason, the Client shall pass the URL it used to connect to the Endpoint to this Service.The implementation of this Service shall use this information to return responses that are accessible to the Client via the provided URL.”
ie; when a client makes a call to an OPC UA Server to discover the endpoints to which it can connect, it is the server's responsibility to return endpoints that the client can discover. Because the server may be available on multiple hostnames (for example, the IP address, the hostname, or multiple IP addresses if there are multiple network cards) the server needs to use the hostname/IP sent by the client to construct the right endpoints.
Fix:
A short-term solution involves the client machine "registering" the server's hostname locally along with the network path used to connect to the server. The client's HOSTS file can include the IP address and hostname in the C:\Windows\System32\Drivers\etc\hosts file.
For e.g. add a line as follows to the above file in your system:
192.168.100.10 raspberrypi
In the long run, it is crucial to ensure that the server is configured to offer endpoints accessible through all available paths.