BadUnexpectedError connecting to server (using Basic Client Example)

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

Moderator: uasdknet

Post Reply
ines80
Jr. Member
Jr. Member
Posts: 1
Joined: 22 May 2012, 11:45

BadUnexpectedError connecting to server (using Basic Client Example)

Post by ines80 »

Hi,

Using the BasicClient example as a starting point, I am trying to connect to a UA Data Access Server (wrapped OPC Server, using Foundation Quickstart Wrapper). I am using the evaluation version of the .NET Client SDK 2.0.

Code: Select all

m_session.Connect(textBoxServer.Text, SecuritySelection.None);


results in a StatusException (BadUnexpectedError) with error message "Der angegebene Host ist unbekannt.".

The server is running and I can connect to the server with UAExpert from the same development machine without problems. Windows Firewall is configured to allow all communication from the client. Inspection of the EndpointDescription property of m_session after the exception has occured shows the correct values for the server.

Setting the SecuritySelection to BestAvailable, accepting the untrusted certificate and supressing the hostname mismatch results in the same error message when trying to connect.

What could be the cause of this error and can you try to provide some clues on how to solve the problem?

Regards,
Ines D.

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

Re:BadUnexpectedError connecting to server (using Basic Client Example)

Post by Support Team »

Hi Ines,

Can you provide the DER file of the Server certificate (may be a parsing problem) and the exact URL that is being passed into the SDK.

Do you have more than one active NIC in the machine (two would explain different lookup behaviour for .NET and C++).

Can you please create traces with trace level Info?
You can change the trace level in BasicClient.exe.config

Please send the requested files to support@unifiedautomation.com

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

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

Re:BadUnexpectedError connecting to server (using Basic Client Example)

Post by Support Team »

Hi Ines,

Based on your input this seems to be a host name resolution problem.

(1) The Quickstart Wrapper is configured to provide a Host Name in the ServerUrl of the EndpointDescription.
(2) You are using the IP-address in the ServerUrl to connect to the wrapper - we assume host name to IP-address resolution is not working
(3) The Basic Client is using the simple Connect of the .NET client SDK. This version of connect is calling GetEndpoints on the server to get all information necessary to connect. Connect is then using the ServerUrl from the EndpointDescription. Since the server is providing a host name in the ServerUrl and host name to IP-address resolution fails, the connect fails.

We will enhance the handling for these cases in the simple connect.

Workarounds are
(1) Wrapper: Configure the Quickstart Wrapper to provide the IP-address in the ServerUrl instead of the host name
(2) .NET Client: Use Discovery.GetEndpoints() to get the EndpointDescription, replace the URL with the IP-address version and call the Connect that takes an EndpointDescription
(3) Use UaGateway instead of the wrapper. UaGateway allows configuring the ServerUrl for the Endpoints

Best Regards,
Unified Automation Support Team
Best regards
Unified Automation Support Team

Post Reply