Session.Connect - No such host is known

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

Moderator: uasdknet

Post Reply
JonLor
Hero Member
Hero Member
Posts: 48
Joined: 30 Jan 2014, 11:05

Session.Connect - No such host is known

Post by JonLor »

Hello,

I have experienced some strange (to me at least) behavior when calling Session.Connect. It seems that if the Session.UpdateEndpoint event is registered with an empty event handler, my connect operation will fail with a StatusException with the message "No such host is known". A sample below:

Code: Select all

public partial class MainWindow : Window
  {
    private ApplicationInstance _application;

    private Session _session;

    public MainWindow()
    {
      InitializeComponent();

      _application = new ApplicationInstance { AutoCreateCertificate = true };
      _application.Start();

      _session = new Session(_application);
      _session.UseDnsNameAndPortFromDiscoveryUrl = true;
      _session.UpdateEndpoint += SessionOnUpdateEndpoint;  // If this line is commented, the connect works
    }

    private void SessionOnUpdateEndpoint(Session sender, UpdateEndpointEventArgs e)
    {
    }
    
    private void Button_Click(object sender, RoutedEventArgs e)
    {
      _session.Connect(@"opc.tcp://172.16.0.1:48010", SecuritySelection.None, _session.DefaultRequestSettings);
    }
  }
Is some action required when registering this event? I noticed that if I set e.UseDnsNameAndPortFromDiscoveryUrl=true it will work.

In what situations should I register for this event, and what are the actions one should take?

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

Re: Session.Connect - No such host is known

Post by Support Team »

Hello,

Session.UseDnsNameAndPortFromDiscoveryUrl and Session.UpdateEndpoint are different ways to solve problems with clients that are not able to resolve DNS names.

To establish a connection, the client needs to know the available Endpoints of a server. For this purpose, GetEndpoints is called first. The server then returns a list of available Endpoints, which may contain host names which the client cannot resolve and thus is not able to connect to these Endpoints.

If The EndpointUpdate EventHandler is used, Session.UseDnsNameAndPortFromDiscoveryUrl is not evaluated. In this case the UseDnsNameAndPortFromDiscoveryUrl from the UpdateEndpointEventArgs class is evaluated.

See http://documentation.unified-automation ... mple5.html.

Best regards
Support Team

Post Reply