Error -356698 When Connecting to Server Using OPC UA Toolkit

Updated May 3, 2023

Reported In

Software

  • LabVIEW
  • LabVIEW 2017
  • LabVIEW OPC UA Toolkit
  • LabVIEW 2017 OPC UA Toolkit

Issue Details

I am using the OPC UA Toolkit with LabVIEW. On my client machine when trying to connect to the server, I receive Error -356698: Unable to locate the host. Ensure the hostname is valid or use the IP address. How can I resolve this error and connect to the server?

Solution

The solution will depend if your client machine is running Windows or if it is a Linux Real-Time target controller:

 

Client on a Windows computer

  1. Find the hosts file located in C:\Windows\System32\drivers\etc\hosts
  2. Using Notepad or any text file software, add the hostname of your server and its IP address to the hosts file. The format should follow the example and instructions included in the hosts file.


Client on a Linux Real-Time controller

  1. Open NI MAX and locate your Real-Time controller under Remote Systems.
  2. Ensure that the Enable Secure Shell Server (sshd) box is checked in Startup Settings.
  3. Click Save and reboot the target if prompted.
  4. Follow the instructions for FileZilla via SFTP located in the article Tools Available for File Transfer/Access on NI Linux Real-Time Target.
  5. Use FileZilla to copy the hosts file located at /etc/hosts to your host computer.
  6. Edit the hosts file in Notepad or any text editor to add the IP address and hostname of the server computer as shown in the screenshot above and save the file.
  7. Use FileZilla to copy the edited hosts file back to the /etc folder on the Real-Time controller. If prompted to replace the existing file, click Yes.
  8. Restart the controller and run your application again to see if the OPC UA error has been resolved.
Note: You can also edit the hosts file on the Linux RT target by accessing the target through a terminal program such as PuTTY and using the built-in Linux text editor.

Additional Information

This error can be thrown when the computer does not know how to resolve the server hostname with its IP address. It can occur even when you specify the IP address of the server instead of the hostname for the Server Endpoint URL input to the OPC UA Client Connect.vi.

Changes were made to the LabVIEW OPC UA Toolkit version 2018 and later to prevent this error from occurring.