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 browseRequest = new BrowseRequest {
NodeId = NodeId.Parse(ObjectIds.ObjectsFolder),
BrowseDirection = BrowseDirection.Forward,
ReferenceTypeId = NodeId.Parse(ReferenceTypeIds.HierarchicalReferences),
NodeClassMask = (uint)NodeClass.Unspecified,
ResultMask = (uint)BrowseResultMask.All,
RequestedMaxReferencesPerNode = 1000
var browseResponse = await channel.BrowseAsync(browseRequest).ConfigureAwait(false);
Console.WriteLine("\n+ Objects, Object, i=85");
foreach (var rd in browseResponse.Results[0].References)
Console.WriteLine($" + {rd.DisplayName}, {rd.NodeClass}, {rd.NodeId}");
var cp = browseResponse.Results[0].ContinuationPoint;
var browseNextRequest = new BrowseNextRequest { ContinuationPoints = new[] { cp }, ReleaseContinuationPoints = false };
var browseNextResponse = await channel.BrowseNextAsync(browseNextRequest);
foreach (var rd in browseNextResponse.Results[0].References)
Console.WriteLine($" + {rd.DisplayName}, {rd.NodeClass}, {rd.NodeId}");
cp = browseNextResponse.Results[0].ContinuationPoint;
Console.WriteLine($"\nClosing session '{channel.SessionId}'.");
await channel.CloseAsync();
await channel.AbortAsync();
Console.WriteLine(ex.Message);