using System.Threading.Tasks;
using Workstation.ServiceModel.Ua;
using Workstation.ServiceModel.Ua.Channels;
public static async Task Main()
var clientDescription = new ApplicationDescription
ApplicationName = "Workstation.UaClient.FeatureTests",
ApplicationUri = $"urn:{System.Net.Dns.GetHostName()}:Workstation.UaClient.FeatureTests",
ApplicationType = ApplicationType.Client
var channel = new UaTcpSessionChannel(
"opc.tcp://opcua.rocks:4840",
SecurityPolicyUris.None);
await channel.OpenAsync();
Console.WriteLine($"Opened session with endpoint '{channel.RemoteEndpoint.EndpointUrl}'.");
Console.WriteLine($"SecurityPolicy: '{channel.RemoteEndpoint.SecurityPolicyUri}'.");
Console.WriteLine($"SecurityMode: '{channel.RemoteEndpoint.SecurityMode}'.");
Console.WriteLine($"UserIdentityToken: '{channel.UserIdentity}'.");
var readRequest = new ReadRequest {
NodeId = NodeId.Parse(VariableIds.Server_ServerStatus),
AttributeId = AttributeIds.Value
var readResult = await channel.ReadAsync(readRequest);
var serverStatus = readResult.Results[0].GetValueOrDefault<ServerStatusDataType>();
Console.WriteLine("\nServer status:");
Console.WriteLine(" ProductName: {0}", serverStatus.BuildInfo.ProductName);
Console.WriteLine(" SoftwareVersion: {0}", serverStatus.BuildInfo.SoftwareVersion);
Console.WriteLine(" ManufacturerName: {0}", serverStatus.BuildInfo.ManufacturerName);
Console.WriteLine(" State: {0}", serverStatus.State);
Console.WriteLine(" CurrentTime: {0}", serverStatus.CurrentTime);
Console.WriteLine($"\nClosing session '{channel.SessionId}'.");
await channel.CloseAsync();
await channel.AbortAsync();
Console.WriteLine(ex.Message);