opcfoundation / ua-.netstandard-samples Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hi friends,
Can you please guide me the correct steps/sequence to run an OPC UA Server with reverse connection and connect an OPC UA Client with reverse connection. I badly need it for my work to complete. Please guide me on which project to build and run first followed by the other. Basically the sequence. Also please do guide me on any hacks or extra steps to be taken care for reverse connection to work.
Please also guide me on what exactly needs to be passed to the reverse connection manager uri. and also the Server uri. I am getting confusion over this in the OPC Client with reverse connection.
I could see lot of Server and Client projects, So really getting baffled around on which project to pick up and the correct sequence to be followed. Please help.
Thanks & Regards
Aravind S.
I have made up the OPC UA Server with Reverse Connect. (Matrikon Dispatcher). It is able to do reverse connection with the Matrikon dispatcher client tool.
Tried the same OPC Client scenario with ComplexClient project in the client machine but met with the below error.
Please let me know what should be set for the ReverseConnectUri.
ReverseConnectManager reverseConnectManager = null;
if (ReverseConnectUri != null)
{
// start the reverse connection manager
reverseConnectManager = new ReverseConnectManager();
reverseConnectManager.AddEndpoint(**ReverseConnectUri**);
reverseConnectManager.StartService(config);
}
Getting the below TransportListenerBindings exception at OPC UA Client with reverse connection.
opc.tcp://10.157.55.140:56000System.AggregateException: One or more errors occurred. (The type initializer for 'Opc.Ua.Bindings.TransportListenerBindings' threw an exception.) ---> System.TypeInitializationException: The type initializer for 'Opc.Ua.Bindings.TransportListenerBindings' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Opc.Ua.Bindings.TcpListener.Dispose(Boolean disposing)
at Opc.Ua.Bindings.TransportListenerBindings.IsTransportListenerType(Type systemType)
at System.Linq.Enumerable.WhereArrayIterator1.MoveNext() at Opc.Ua.Bindings.TransportListenerBindings..cctor() --- End of inner exception stack trace --- at Opc.Ua.Bindings.TransportListenerBindings.GetTransportListener(String uriScheme) at Opc.Ua.ReverseConnectHost.CreateListener(Uri url, EventHandler1 OnConnectionWaiting, EventHandler1 OnConnectionStatusChanged) at Opc.Ua.Client.ReverseConnectManager.AddEndpointInternal(Uri endpointUrl, Boolean configEntry) at Opc.Ua.Client.ReverseConnectManager.AddEndpoint(Uri endpointUrl) at NetCoreConsoleClient.MySampleClient.ConsoleSampleClient() in C:\Users\Administrator\source\repos\NetCoreComplexClient\Program.cs:line 279 --- End of inner exception stack trace --- at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)
at NetCoreConsoleClient.MySampleClient.Run() in C:\Users\Administrator\source\repos\NetCoreComplexClient\Program.cs:line 203
---> (Inner Exception #0) System.TypeInitializationException: The type initializer for 'Opc.Ua.Bindings.TransportListenerBindings' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Opc.Ua.Bindings.TcpListener.Dispose(Boolean disposing)
at Opc.Ua.Bindings.TransportListenerBindings.IsTransportListenerType(Type systemType)
at System.Linq.Enumerable.WhereArrayIterator1.MoveNext() at Opc.Ua.Bindings.TransportListenerBindings..cctor() --- End of inner exception stack trace --- at Opc.Ua.Bindings.TransportListenerBindings.GetTransportListener(String uriScheme) at Opc.Ua.ReverseConnectHost.CreateListener(Uri url, EventHandler1 OnConnectionWaiting, EventHandler1 OnConnectionStatusChanged) at Opc.Ua.Client.ReverseConnectManager.AddEndpointInternal(Uri endpointUrl, Boolean configEntry) at Opc.Ua.Client.ReverseConnectManager.AddEndpoint(Uri endpointUrl) at NetCoreConsoleClient.MySampleClient.ConsoleSampleClient() in C:\Users\Administrator\source\repos\NetCoreComplexClient\Program.cs:line 279<--- opc.tcp://10.157.55.140:56000System.AggregateException: One or more errors occurred. (The type initializer for 'Opc.Ua.Bindings.TransportListenerBindings' threw an exception.) ---> System.TypeInitializationException: The type initializer for 'Opc.Ua.Bindings.TransportListenerBindings' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Opc.Ua.Bindings.TcpListener.Dispose(Boolean disposing) at Opc.Ua.Bindings.TransportListenerBindings.IsTransportListenerType(Type systemType) at System.Linq.Enumerable.WhereArrayIterator1.MoveNext()
at Opc.Ua.Bindings.TransportListenerBindings..cctor()
--- End of inner exception stack trace ---
at Opc.Ua.Bindings.TransportListenerBindings.GetTransportListener(String uriScheme)
at Opc.Ua.ReverseConnectHost.CreateListener(Uri url, EventHandler1 OnConnectionWaiting, EventHandler1 OnConnectionStatusChanged)
at Opc.Ua.Client.ReverseConnectManager.AddEndpointInternal(Uri endpointUrl, Boolean configEntry)
at Opc.Ua.Client.ReverseConnectManager.AddEndpoint(Uri endpointUrl)
at NetCoreConsoleClient.MySampleClient.ConsoleSampleClient()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at NetCoreConsoleClient.MySampleClient.Run() ---> (Inner Exception #0) System.TypeInitializationException: The type initializer for 'Opc.Ua.Bindings.TransportListenerBindings' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at Opc.Ua.Bindings.TcpListener.Dispose(Boolean disposing) at Opc.Ua.Bindings.TransportListenerBindings.IsTransportListenerType(Type systemType) at System.Linq.Enumerable.WhereArrayIterator1.MoveNext()
at Opc.Ua.Bindings.TransportListenerBindings..cctor()
--- End of inner exception stack trace ---
at Opc.Ua.Bindings.TransportListenerBindings.GetTransportListener(String uriScheme)
at Opc.Ua.ReverseConnectHost.CreateListener(Uri url, EventHandler1 OnConnectionWaiting, EventHandler1 OnConnectionStatusChanged)
at Opc.Ua.Client.ReverseConnectManager.AddEndpointInternal(Uri endpointUrl, Boolean configEntry)
at Opc.Ua.Client.ReverseConnectManager.AddEndpoint(Uri endpointUrl)
at NetCoreConsoleClient.MySampleClient.ConsoleSampleClient()<---
opc.tcp://10.157.55.140:56000
hi i used kepserver_HDA server, in UAExpert i can see source timestamp and server timestamp 10hrs difference can i get to know why .
Any help is highly appreciated :)
Hello,
I am currently developing a client OPCUA program for a WAGO PLC.
I am using your program as a reference.
While testing my program's operation, I noticed that when I perform a browse operation to retrieve a collection of nodes with the network cable unplugged the program freeze on the 'm_browser.Browse (RootNodeIDParent)' command.
I tried to use a try and catch without success.
There is no error return.
The problem is the same on your program.
Is there a solution to detect an error when disconnecting the network cable?
Private Sub FindNodesChildrenTableau (RootNodeIDParent As NodeId)
'Options to be used for the navigation operation
m_browser = New Browser (m_session) With {.BrowseDirection = BrowseDirection.Forward, .ContinueUntilDone = True, .ReferenceTypeId = ReferenceTypeIds.HierarchicalReferences}
'Collection of child variables from parent variable
Dim RdcOrg As ReferenceDescriptionCollection = m_browser.Browse (RootNodeIDParent)
(Freeze program on the line above)
...
...
End sub
I also have an error fetching issue on the await Session.Create () command surrounded by a try and catch.
The error detected for example 'BadCertificateHostNameInvalid' does not go through the Try and Catch.
Try
....
m_session = await Session.Create (m_configuration, endpoint, false, true, Application.ProductName, 60000, identity, nothing)
....
catch
....
Hellow everyone,
I'm trying to implement Files in my Opc.Ua server C#. I haven't got much experience in Opc.ua (a couple of weeks) but in documentation I've seen the ObjectType FileType. I've found it in me solution in Opc.Ua.Core\Stack\Generated\Opc.Ua.Classes.cs(4320). My beginner problem is that I'm not able to declare a instante in my AdressSpace :
FyleType myfile.
The avalible options are : FileDirectoryState, FileState or UABinaryFileDataType.
I'm able to create folders and simples variables/events and watch them in my client but files imposible.
Thank you.
Set up a monitored item whose status is BadWaitingForInitialValue. Try and write a value and get this exception:
Object reference not set to an instance of an object.
STACK TRACE
at Quickstarts.DataAccessClient.WriteValueDlg.ChangeType() in D:\Sourcetree\OPC UA\UA-.NETStandard\SampleApplications\Workshop\DataAccess\Client\WriteValueDlg.cs:line 122at Quickstarts.DataAccessClient.WriteValueDlg.OkBTN_Click(Object sender, EventArgs e) in D:\Sourcetree\OPC UA\UA-.NETStandard\SampleApplications\Workshop\DataAccess\Client\WriteValueDlg.cs:line 213
Hi.
First of all - I am really new to OPC UA.
I browse the Samples and Workshops but I struggle to find the simple way to write to a single node the desired value I want.
For now I was able to build and run a simple OPC UA Client application base entirely on NetCoreConsoleClient example.
I can browse all the parts of the data block which I have access to using the Session
object and its Browse
method. Then using the foreach
cycle i can loop through ReferenceDescriptionCollection
. Then I can access the inner structure of the data block find the Node I want to go in using comparation with DisplayName.Text
and using another foreach cycle go inside and so on.
My question is:
How can I access the value of the specific Node directly? I found an example using NodeId but I struggle to recognize what the NodeId is really? How can I determine the NodeId if I know the structure of the datablock? Is it something I can find in the OPC Server?
My usecase is quite simple:
I need to examine a value of the specific Node once a 100ms and if it changes I need to read some more Nodes' values and then write a response using another Node.
I just need a kick to my butt in the right direction.
Thank you very much for any help.
Kind regards,
Zdeněk Neustupa
I would like to know if it would be possible to use the OPC UA Server from the "UA Universal Windows.sln" project on the Raspberry Pi 3B with Windows IoT.
To test it, I initially tried to run the server and client for this project on the same Windows 10 PC. Both run. On the client, when asking to connect to the server, a screen is presented with parameters already filled in. I didn't change anything. I clicked "OK". The message "Endpoint information may be out of date because the discovery process has not completed. Continue anyway?" appears. I selected "Yes". The exception is shown: "Caller: EndpointSelectorCTRL_ConnectEndpoint; Exception: Value cannot be null; Parameter name: serverCertificate".
I ran the client and server from the "DataAccess" folder of the "UA Quickstart Applications.sln" project without any problems.
Hi all,
I'm trying to add historical access capabilities to the aggregator server since it doesn't support it. I'm currently trying to mash up the Historical Access Server example from the Quickstart apps and the Aggregator server, I think the important pieces are the HistircalAccessNodeManager and the underlying system classes (correct me if I'm wrong please). But I just bumped into an issue; there's a GetManagerHandle
method override in the NodeManager classes (both Historical and Custom) that I'm not sure why isn't working properly, it seems like it's not able to find the requested node anywhere.
Has anyone tried to implement this? Any advice will be much appreciated.
Hello,
With visual studio 2019 version 16.8.3, after building the solution for your OPC UA .Net Standard Samples project, I find the following errors:
To solve the problem of .resx files, I check the Unblock box in their properties, on the General tab.
For the following errors:
Metadata file 'D: \ Downloads \ Chrome_Téléchargement \ UA-.NETStandard-Samples-master \ UA-.NETStandard-Samples-master \ Samples \ Controls.Net4 \ bin \ Debug \ Opc.Ua.SampleControls.dll' not found
Metadata file 'D: \ Downloads \ Chrome_Téléchargement \ UA-.NETStandard-Samples-master \ UA-.NETStandard-Samples-master \ Samples \ ClientControls.Net4 \ bin \ Debug \ Opc.Ua.ClientControls.dll' not found
What is the solution to solve this problem?
I found the NetCoreConsoleClient example to be the easiest to learn from, but it would have been really really great if there was an example of how to write to a variable in that example as well.
Hello,
I made following code changes in NetCoreConsoleClient app.
namespace WindowsFormsApp8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Run()
{
//Console.WriteLine("Step 1 - Create application configuration and certificate.");
var config = new ApplicationConfiguration()
{
ApplicationName = "MyHomework",
ApplicationUri = Utils.Format(@"urn:{0}:MyHomework", System.Net.Dns.GetHostName()),
ApplicationType = ApplicationType.Client,
SecurityConfiguration = new SecurityConfiguration
{
ApplicationCertificate = new CertificateIdentifier { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\MachineDefault", SubjectName = "MyHomework" },
TrustedIssuerCertificates = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\UA Certificate Authorities" },
TrustedPeerCertificates = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\UA Applications" },
RejectedCertificateStore = new CertificateTrustList { StoreType = @"Directory", StorePath = @"%CommonApplicationData%\OPC Foundation\CertificateStores\RejectedCertificates" },
AutoAcceptUntrustedCertificates = true
},
TransportConfigurations = new TransportConfigurationCollection(),
TransportQuotas = new TransportQuotas { OperationTimeout = 15000 },
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60000 },
TraceConfiguration = new TraceConfiguration()
};
config.Validate(ApplicationType.Client).GetAwaiter().GetResult();
if (config.SecurityConfiguration.AutoAcceptUntrustedCertificates)
{
config.CertificateValidator.CertificateValidation += (s, e) => { e.Accept = (e.Error.StatusCode == StatusCodes.BadCertificateUntrusted); };
}
var application = new ApplicationInstance
{
ApplicationName = "MyHomework",
ApplicationType = ApplicationType.Client,
ApplicationConfiguration = config
};
application.CheckApplicationInstanceCertificate(false, 2048).GetAwaiter().GetResult();
var selectedEndpoint = CoreClientUtils.SelectEndpoint("opc.tcp://dell-g7-7588:62546/Quickstarts/EmptyServer", useSecurity: false, operationTimeout: 15000);
//Console.WriteLine($"Step 2 - Create a session with your server: {selectedEndpoint.EndpointUrl} ");
using (var session = Session.Create(config, new ConfiguredEndpoint(null, selectedEndpoint, EndpointConfiguration.Create(config)), false, "", 60000, null, null).GetAwaiter().GetResult())
{
//Console.WriteLine("Step 3 - Browse the server namespace.");
ReferenceDescriptionCollection refs;
Byte[] cp;
session.Browse(null, null, ObjectIds.ObjectsFolder, 0u, BrowseDirection.Forward, ReferenceTypeIds.HierarchicalReferences, true, (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, out cp, out refs);
//Console.WriteLine("DisplayName: BrowseName, NodeClass");
foreach (var rd in refs)
{
//Console.WriteLine("{0}: {1}, {2}", rd.DisplayName, rd.BrowseName, rd.NodeClass);
ReferenceDescriptionCollection nextRefs;
byte[] nextCp;
session.Browse(null, null, ExpandedNodeId.ToNodeId(rd.NodeId, session.NamespaceUris), 0u, BrowseDirection.Forward, ReferenceTypeIds.HierarchicalReferences, true, (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, out nextCp, out nextRefs);
//foreach (var nextRd in nextRefs)
//{
// Console.WriteLine("+ {0}: {1}, {2}", nextRd.DisplayName, nextRd.BrowseName, nextRd.NodeClass);
//}
}
//Console.WriteLine("Step 4 - Create a subscription. Set a faster publishing interval if you wish.");
var subscription = new Subscription(session.DefaultSubscription) { PublishingInterval = 1000 };
//Console.WriteLine("Step 5 - Add a list of items you wish to monitor to the subscription.");
var list = new List<MonitoredItem> { new MonitoredItem(subscription.DefaultItem) { DisplayName = "Meihk", StartNodeId = "ns=2;i=6" } };
list.ForEach(i => i.Notification += OnNotification);
subscription.AddItems(list);
//Console.WriteLine("Step 6 - Add the subscription to the session.");
session.AddSubscription(subscription);
subscription.Create();
//Console.WriteLine("Press any key to remove subscription...");
//Console.ReadKey(true);
while(true)
{
}
}
//Console.WriteLine("Press any key to exit...");
//Console.ReadKey(true);
}
public void OnNotification(MonitoredItem item, MonitoredItemNotificationEventArgs e)
{
foreach (var value in item.DequeueValues())
{
//Console.WriteLine("{0}: {1}, {2}, {3}", item.DisplayName, value.Value, value.SourceTimestamp, value.StatusCode);
label1.Text = value.Value.ToString();
}
}
}
}
`
The problem is, the command line "label1.Text=value.Value.ToString();" in OnNotification didn't execute.
Can you show me the problem?
2) The code is only to read variable value from Server. Is it possible to add some codeline to write value? And if so, please give me some instruction. Thank you so much
I am encountering an issue with DataAccessClient sample. After connection with at least one monitored item, when reconnecting and try monitoring any items i get the following exception:
Is this known issue? How do you clean up the monitored data so when connecting again you can add the items or when reconnecting for monitored data to remain there and continue to be monitored?
What I try:
Try to adapt the NetCoreConsoleClient for HoloLens:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Opc.Ua;
using Opc.Ua.Client;
using Opc.Ua.Configuration;
public class main : MonoBehaviour
{
private async void Start()
{
Console.WriteLine("Step 1 - Create a config.");
var config = new ApplicationConfiguration()
{
ApplicationName = "test-opc",
ApplicationType = ApplicationType.Client,
SecurityConfiguration = new SecurityConfiguration { ApplicationCertificate = new CertificateIdentifier() },
TransportConfigurations = new TransportConfigurationCollection(),
TransportQuotas = new TransportQuotas { OperationTimeout = 15000 },
ClientConfiguration = new ClientConfiguration { DefaultSessionTimeout = 60000 }
};
await config.Validate(ApplicationType.Client);
if (config.SecurityConfiguration.AutoAcceptUntrustedCertificates)
{
config.CertificateValidator.CertificateValidation += (s, e) => { e.Accept = (e.Error.StatusCode == StatusCodes.BadCertificateUntrusted); };
}
Console.WriteLine("Step 2 - Create a session with your server.");
using (var session = await Session.Create(config, new ConfiguredEndpoint(null, new EndpointDescription("opc.tcp://localhost:4841")), true, "", 60000, null, null))
{
Console.WriteLine("Step 3 - Browse the server namespace.");
ReferenceDescriptionCollection refs;
byte[] cp;
session.Browse(null, null, ObjectIds.ObjectsFolder, 0u, BrowseDirection.Forward, ReferenceTypeIds.HierarchicalReferences, true, (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, out cp, out refs);
Console.WriteLine("DisplayName: BrowseName, NodeClass");
foreach (var rd in refs)
{
Console.WriteLine(rd.DisplayName + ": " + rd.BrowseName + ", " + rd.NodeClass);
ReferenceDescriptionCollection nextRefs;
byte[] nextCp;
session.Browse(null, null, ExpandedNodeId.ToNodeId(rd.NodeId, session.NamespaceUris), 0u, BrowseDirection.Forward, ReferenceTypeIds.HierarchicalReferences, true, (uint)NodeClass.Variable | (uint)NodeClass.Object | (uint)NodeClass.Method, out nextCp, out nextRefs);
foreach (var nextRd in nextRefs)
{
Console.WriteLine("+ " + nextRd.DisplayName + ": " + nextRd.BrowseName + ", " + nextRd.NodeClass);
}
}
Console.WriteLine("Step 4 - Create a subscription. Set a faster publishing interval if you wish.");
var subscription = new Subscription(session.DefaultSubscription) { PublishingInterval = 1000 };
Console.WriteLine("Step 5 - Add a list of items you wish to monitor to the subscription.");
var list = new List<MonitoredItem> {
new MonitoredItem(subscription.DefaultItem) { DisplayName = "aaatime", StartNodeId = "i=10004" } };
list.ForEach(i => i.Notification += OnNotification);
subscription.AddItems(list);
Console.WriteLine("Step 6 - Add the subscription to the session.");
session.AddSubscription(subscription);
subscription.Create();
Console.WriteLine("Finished client initialization");
}
}
private static void OnNotification(MonitoredItem item, MonitoredItemNotificationEventArgs e)
{
foreach (var value in item.DequeueValues())
{
Console.WriteLine("{0}: {1}, {2}, {3}", item.DisplayName, value.Value, value.SourceTimestamp, value.StatusCode);
}
}
}
What I got => several errors, some of them:
Severity Code Description Project File Line Suppression State
Error CS0012 The type 'X509CertificateValidator' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ServiceModel.Primitives, Version=4.5.0.3, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Test C:\Users\hidethepain\Documents\opc\Assets\main.cs 27
Severity Code Description Project File Line Suppression State
Error CS0012 The type 'Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Test, Test.Player C:\Users\hidethepain\Documents\opc\Assets\main.cs 18 Active
Severity Code Description Project File Line Suppression State
Error CS0012 The type 'Task<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Test, Test.Player C:\Users\hidethepain\Documents\opc\Assets\main.cs 31 Active
Which Versions I use:
Unity3D editor: 2018.2.14f1
Visual studio: 2017
UWP Sdk: 10.0.15063.0
Scripting Runtime Version: .Net 4.x
Scripting Backend: IL2CPP.
API Compatibility Level: .Net 4.x
I think I got a mixup with the different versions of .net. I really need a very simple console example of an opc client which is reading/writing from/to one node (one endpoint / variable).
-Which example should I take?
-Which versions of .net/unity/visual studio/opc libraries should I take?
Hello!
I'm trying to write UA Wrapper based on your UA Com Server Wrapper, but nothing happens if DA item's quality changed? Can you advice me something?
Hello,
I am having issue with call in ComClient.cs in public void SetUserIdentity(IUserIdentity identity)
while calling
IOPCSecurityPrivate server = BeginComCall<IOPCSecurityPrivate>(methodName, true);
I did some investigation and I found that I cannot load the "7AA83A02-6C77-11d3-84F9-00008630A38B" which supposes to be IOPCSecurityPrivate.
My code for testing:
[ComImport]
[GuidAttribute("7AA83A02-6C77-11d3-84F9-00008630A38B")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOPCSecurityPrivate
{
void Logon(
[MarshalAs(UnmanagedType.LPWStr)]
string szUserID,
[MarshalAs(UnmanagedType.LPWStr)]
string szPassword);
};
call
[System.Runtime.InteropServices.DllImport("ole32.dll")]
public static extern int CoInitializeSecurity(IntPtr pVoid, int
cAuthSvc, IntPtr asAuthSvc, IntPtr pReserved1, RpcAuthnLevel level,
RpcImpLevel impers, IntPtr pAuthList, EoAuthnCap dwCapabilities, IntPtr
pReserved3);
[System.Runtime.InteropServices.DllImport("ole32.dll")]
public static extern void CoUninitialize();
[ComImport, Guid("7AA83A02-6C77-11d3-84F9-00008630A38B")]
class OPCSecurityPrivate
{
}
static void Main(string[] args)
{
/*Console.WriteLine("System.Threading.Thread.CurrentThread.ApartmentState: {0}", System.Threading.Thread.CurrentThread.GetApartmentState());
System.Threading.Thread.CurrentThread.ApartmentState = ApartmentState.STA;
Console.WriteLine("System.Threading.Thread.CurrentThread.ApartmentState: {0}", System.Threading.Thread.CurrentThread.GetApartmentState());*/
int hr;
hr = CoInitializeSecurity(IntPtr.Zero, -1, IntPtr.Zero,
IntPtr.Zero, RpcAuthnLevel.None,
RpcImpLevel.Impersonate, IntPtr.Zero, EoAuthnCap.None, IntPtr.Zero);
OPCSecurityPrivate opcSecutiry = new OPCSecurityPrivate();
IOPCSecurityPrivate IopcSecutiry = (IOPCSecurityPrivate)opcSecutiry;
CoUninitialize();
}
When I run the program I get an error:
Unhandled Exception: System.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {7AA83A02-6C77-11D3-84F9-00008630A38B} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
at IOPCSecurityPrivateTest.Program.Main(String[] args) in C:\Tools\IOPCSecurityPrivateTest\IOPCSecurityPrivateTest\Program.cs:line 76
While running the UA COM Interop Library I am getting an error:
IOPCSecurityPrivate.Logon NotSupportedException 'COM interface 'IOPCSecurityPrivate' is not supported by server.'
Could anybody can help me with fixing it?
Thanks a lot Rudo
Hi
Please don't mind me asking. I see lot of check-ins going on in the Reverse Connect part. As I am fully relying o your code and nuget packages for my development work. Kindly let me know whether the support for reverse connect is fully done or is it still in development.
Please also guide me in 4-5 steps on how to setup the OPC UA Server and OPC UA Client reverse connection. That will be helpfull.
Hi. I connect a Real PLC S7 - 1500 as a OPC UA Client to .Net Server Application.
It's OK when i use Connect FB -> GetNamespaceIndexList FB until the NodeGetHandleList FB -> ReadList or WriteList FB.
So when I use the readlist and writelist block, It has the error 16#8034_0000 (BadNodeIDUnknown).
I tested with a simple SIMATIC OPC UA Server, it can read or write with StatusCode Good.
Can you investigate the .Net Server sample Application and resolve this?? Thank you
I put link of OPC UA Client FB below:
https://support.industry.siemens.com/cs/document/109762770/s7-user-block-for-the-opc-ua-client-of-a-simatic-s7-1500?dti=0&lc=en-WW.
Hello everyone,
I'm new to working with OPC UA and I'm trying out this sample GDS with sample client and server and I have few questions if you could answer me.
Thank you,
Lena
Hi Everyone,
This is regarding UA COM Interop Library IOPCSecurityPrivate.Logon method. I have a server (clear scada) which support the private security (IOPCSecurityPrivate) interface.
The COM wrapper Calls Set Identity method. This method Creates the IOPCSecurity object and call the method Logon. It throws exception while loading the IOPCSecurity interface object. Could you please suggest resolution for this issue.
It is also observed that sometime, set Identity method successfully create/load the IOPCSecurity object. Most of the time it fails to load/create.
Below is the log message. But clearscada supports private security. Sometimes it connects successfully and sometime it throws exception.
5/8/2019 15:28:40.052 : IOPCSecurityPrivate.Logon NotSupportedException 'COM interface 'IOPCSecurityPrivate' is not supported by server.'
Hello,
I have been trying to run the GDS server on my Ubuntu 20,04. I have installed the consoleGDS server on my linux machine. Would want to explore the discovery options available. I would like to klńow if there is a console client application as well which could call the queryServers method? or the register application method?
Is the current implementation of the GDS only for windows operating system,apart from the consoleserver?
PS: Totally new to GDS.
Regards,
Rakshan
I'm following the tutorial for aggregation server here.
After I disconnect from aggregation client
to aggregation server
. The sessions between aggregation server
and sample server
are still alive. The clients(I guess there are clients inside aggregation server
to connect to real server for aggregation) inside the aggregation server
won't close those sessions automatically.
Here are my steps:
UA Sample Server
QuickStart Aggregation Server
QuickStart Aggregation Client
QuickStart Aggregation Server
from QuickStart Aggregation Client
QuickStart Aggregation Server
from QuickStart Aggregation Client
I am new to OPC UA,
Our requirement is that the OPC UA Client app will do the reads/write data from/to a backend system (which is the system of record) via a OPC UA server. How can we represent the backend system C# objects in an OPC UA Server? So that the data gets directly updated in the backend system rather being on nodes(nodes object), we are more concerned on the duplicate data in both places (OPC UA server and Backed system) and also the data need to be UPTODATE on both the OPCUA server and backend system.
Please Help
Hello,
I want to receive alarms from an external OPC-UA with the AlarmCondition Client from these Samples.
With UA Expert (a common OPC-UA client) i receive the alarms perfectly.
With the AlarmCondition Client from these Samples there appears nothing
Steps to reproduce
Any help is highly appreciated :)
I've compiled original "UA Xamarin Client" solution and tried to run it on my Android 8.1 device and found that i can't connect to OPC-UA server. Application simply hangs on connection attempt.
During debugging i found that the problem is in the file Opc.Ua.Core/Security/Certificates/DirectoryCertificateStore.cs line 613:
entry.Certificate = new X509Certificate2(file.FullName);
This line of code never finishes. I tried to comment this code, but it hangs further (also when trying to make some manipulations with certificates).
So, the sample is completely broken :-/
In a project we're seeing the below exception when using the UA COM Server Wrapper. We're running against a Cimplicity 8.1 and 8.2 OPC DA Servers. We have the UA COM Server Wrapper set up on the same machine as Cimplicity (running Window 7).
We can sample nodes through the Wrapper using UAExpert but when we sample nodes through the Wrapper using the OPC Publisher from Microsoft the following exception is thrown repeatedly by the UA COM Server Wrapper:
Id: Bad Description: Cannot access a disposed object. Object name: 'The COM server has been disposed.'. Cannot access a disposed object. Object name: 'The COM server has been disposed.' --- at Opc.Ua.Com.Client.ComObject.BeginComCall[T](String methodName, Boolean throwOnError) in C:\Users\User\source\repos\UA-.NETStandard\ComIOP\Common\Client\ComObject.cs:line 171 --- at Opc.Ua.Com.Client.ComDaClient.ReadPropertyValues(String itemId, Int32[] propertyIds) in C:\Users\User\source\repos\UA-.NETStandard\ComIOP\Common\Client\Da\ComDaClient.cs:line 843
This happens even if we're just sampling one node every 2 seconds.
Here are the reproduction steps:
Opc.Ua.ComServerWrapper.Config.xml:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationConfiguration
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ua="http://opcfoundation.org/UA/2008/02/Types.xsd"
xmlns="http://opcfoundation.org/UA/SDK/Configuration.xsd">
<ApplicationName>UA COM Server Wrapper</ApplicationName>
<ApplicationUri>urn:localhost:UA:ComServerWrapper</ApplicationUri>
<ProductUri>http://opcfoundation.org/UA/ComServerWrapper</ProductUri>
<ApplicationType>Server_0</ApplicationType>
<SecurityConfiguration>
<!-- Where the application instance certificate is stored (MachineDefault) -->
<ApplicationCertificate>
<StoreType>Directory</StoreType>
<StorePath>%CommonApplicationData%\OPC Foundation\pki\own</StorePath>
<SubjectName>CN=UA COM Server Wrapper, C=US, S=Arizona, O=OPC Foundation, DC=localhost</SubjectName>
</ApplicationCertificate>
<!-- Where the issuer certificate are stored (certificate authorities) -->
<TrustedIssuerCertificates>
<StoreType>Directory</StoreType>
<StorePath>%CommonApplicationData%\OPC Foundation\pki\issuer</StorePath>
</TrustedIssuerCertificates>
<!-- Where the trust list is stored (UA Applications) -->
<TrustedPeerCertificates>
<StoreType>Directory</StoreType>
<StorePath>%CommonApplicationData%\OPC Foundation\pki\trusted</StorePath>
</TrustedPeerCertificates>
<!-- The directory used to store invalid certficates for later review by the administrator. -->
<RejectedCertificateStore>
<StoreType>Directory</StoreType>
<StorePath>%CommonApplicationData%\OPC Foundation\pki\rejected</StorePath>
</RejectedCertificateStore>
<AutoAcceptUntrustedCertificates>false</AutoAcceptUntrustedCertificates>
</SecurityConfiguration>
<TransportConfigurations />
<TransportQuotas>
<OperationTimeout>600000</OperationTimeout>
<MaxStringLength>1048576</MaxStringLength>
<MaxByteStringLength>4194304</MaxByteStringLength>
<MaxArrayLength>65535</MaxArrayLength>
<MaxMessageSize>4194304</MaxMessageSize>
<MaxBufferSize>65535</MaxBufferSize>
<ChannelLifetime>300000</ChannelLifetime>
<SecurityTokenLifetime>3600000</SecurityTokenLifetime>
</TransportQuotas>
<ServerConfiguration>
<BaseAddresses>
<ua:String>opc.tcp://localhost:48400/UA/ComServerWrapper</ua:String>
</BaseAddresses>
<SecurityPolicies>
<ServerSecurityPolicy>
<SecurityMode>SignAndEncrypt_3</SecurityMode>
<SecurityPolicyUri>http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256</SecurityPolicyUri>
</ServerSecurityPolicy>
</SecurityPolicies>
<MinRequestThreadCount>5</MinRequestThreadCount>
<MaxRequestThreadCount>100</MaxRequestThreadCount>
<MaxQueuedRequestCount>2000</MaxQueuedRequestCount>
<!-- The SDK expects the server to support the same set of user tokens for every endpoint. -->
<UserTokenPolicies>
<!-- Allows anonymous users -->
<ua:UserTokenPolicy>
<ua:TokenType>Anonymous_0</ua:TokenType>
<ua:SecurityPolicyUri>http://opcfoundation.org/UA/SecurityPolicy#None</ua:SecurityPolicyUri>
</ua:UserTokenPolicy>
<!-- Allows user certificates -->
<ua:UserTokenPolicy>
<ua:TokenType>Certificate_2</ua:TokenType>
<!-- certificate possession must be proven with a digital signature - this specifies what algorithm to use -->
<ua:SecurityPolicyUri>http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256</ua:SecurityPolicyUri>
</ua:UserTokenPolicy>
</UserTokenPolicies>
<DiagnosticsEnabled>true</DiagnosticsEnabled>
<MaxSessionCount>100</MaxSessionCount>
<MinSessionTimeout>10000</MinSessionTimeout>
<MaxSessionTimeout>3600000</MaxSessionTimeout>
<MaxBrowseContinuationPoints>10</MaxBrowseContinuationPoints>
<MaxQueryContinuationPoints>10</MaxQueryContinuationPoints>
<MaxHistoryContinuationPoints>100</MaxHistoryContinuationPoints>
<MaxRequestAge>600000</MaxRequestAge>
<MinPublishingInterval>100</MinPublishingInterval>
<MaxPublishingInterval>3600000</MaxPublishingInterval>
<PublishingResolution>50</PublishingResolution>
<MaxSubscriptionLifetime>3600000</MaxSubscriptionLifetime>
<MaxMessageQueueSize>100</MaxMessageQueueSize>
<MaxNotificationQueueSize>100</MaxNotificationQueueSize>
<MaxNotificationsPerPublish>1000</MaxNotificationsPerPublish>
<MinMetadataSamplingInterval>1000</MinMetadataSamplingInterval>
<AvailableSamplingRates />
<RegistrationEndpoint>
<ua:EndpointUrl>opc.tcp://localhost:4840</ua:EndpointUrl>
<ua:Server>
<ua:ApplicationUri>opc.tcp://localhost:4840</ua:ApplicationUri>
<ua:ApplicationType>DiscoveryServer_3</ua:ApplicationType>
<ua:DiscoveryUrls>
<ua:String>opc.tcp://localhost:4840</ua:String>
</ua:DiscoveryUrls>
</ua:Server>
<ua:SecurityMode>SignAndEncrypt_3</ua:SecurityMode>
<ua:SecurityPolicyUri />
<ua:UserIdentityTokens />
</RegistrationEndpoint>
<MaxRegistrationInterval>0</MaxRegistrationInterval>
<NodeManagerSaveFile>Opc.Ua.Server.nodes.xml</NodeManagerSaveFile>
<MinSubscriptionLifetime>10000</MinSubscriptionLifetime>
<MaxPublishRequestCount>20</MaxPublishRequestCount>
<MaxSubscriptionCount>100</MaxSubscriptionCount>
<MaxEventQueueSize>10000</MaxEventQueueSize>
</ServerConfiguration>
<Extensions>
<ua:XmlElement>
<ComWrapperServerConfiguration xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://opcfoundation.org/UA/SDK/COMInterop">
<WrappedServers>
<ComClientConfiguration i:type="ComDaClientConfiguration">
<ServerUrl>opc.com://localhost/CIMPLICITY.HMI.OPCServer.1</ServerUrl>
<ServerName>DA</ServerName>
<MaxReconnectWait>10000</MaxReconnectWait>
<SeperatorChars></SeperatorChars>
<AvailableLocales>
<ua:String>en-US</ua:String>
<ua:String>de-DE</ua:String>
<ua:String>ja-JP</ua:String>
</AvailableLocales>
<BrowseToNotSupported>false</BrowseToNotSupported>
</ComClientConfiguration>
</WrappedServers>
</ComWrapperServerConfiguration>
</ua:XmlElement>
</Extensions>
<TraceConfiguration>
<OutputFilePath>%CommonApplicationData%\OPC Foundation\Logs\Opc.Ua.ComServerWrapper.log.txt</OutputFilePath>
<DeleteOnLoad>true</DeleteOnLoad>
<!-- Show Only Errors -->
<!-- <TraceMasks>1</TraceMasks> -->
<!-- Show Only Security and Errors -->
<!-- <TraceMasks>513</TraceMasks> -->
<!-- Show Only Security, Errors and Trace -->
<!-- <TraceMasks>515</TraceMasks> -->
<!-- Show Only Security, COM Calls, Errors and Trace -->
<TraceMasks>1023</TraceMasks>
<!-- Show Only Security, Service Calls, Errors and Trace -->
<!-- <TraceMasks>523</TraceMasks> -->
<!-- Show Only Security, ServiceResultExceptions, Errors and Trace -->
<!-- <TraceMasks>519</TraceMasks> -->
</TraceConfiguration>
</ApplicationConfiguration>
publishednodes.json:
[
{
"EndpointUrl": "opc.tcp://CIMPL:48400/UA/ComServerWrapper",
"OpcNodes": [
{
"Id": "ns=2;s=0:\\\\TESTPROJ\\TESTOBJ.PV.VALUE",
"OpcSamplingInterval": 2000,
"OpcPublishingInterval": 5000,
"HeartbeatInterval": 3600,
"SkipFirst": true
}
]
}
]
Any idea what could be happening here?
I tried to build the Xamarin Sample client. Tried to debug it, but cant fix it. In SampleClient.cs in OPCClient (string endpointURL)
but client skips if (session 1= null) { ... }
and catch this error:
"Opc.Ua.ServiceResultException: The chosen security policy is not supported by the client to connect to the server.
at Opc.Ua.Client.Session.Open (System.String sessionName, System.UInt32 sessionTimeout, Opc.Ua.IUserIdentity identity, System.Collections.Generic.IList`1[T] preferredLocales, System.Boolean checkDomain) [0x00067] in <2a595fc8094149f1b54febea1873146b>:0
at Opc.Ua.Client.Session.Create (Opc.Ua.ApplicationConfiguration configuration, Opc.Ua.ITransportWaitingConnection connection, Opc.Ua.ConfiguredEndpoint endpoint, System.Boolean updateBeforeConnect, System.Boolean checkDomain, System.String sessionName, System.UInt32 sessionTimeout, Opc.Ua.IUserIdentity identity, System.Collections.Generic.IList`1[T] preferredLocales) [0x00294] in <2a595fc8094149f1b54febea1873146b>:0
at XamarinClient.SampleClient.OpcClient (System.String endpointURL) [0x001b9] in C:\Users\Administrator\Desktop\V1\Sample\Samples\XamarinClient\XamarinClient\SampleClient.cs:157 }."
I tried the Server with different clients, so the Server is fine. Maybe the Xamarin Client is just not up to date ?
Then i recieve: Warning: Cannot connect to an OPC UA Server
Please help me
It should be possible to add several certificate groups in the config file to enable several CA.
it looks like that only the last CertificateGroup is kept in the configuration. Furthermore, the other certificate groups can't be displayed in the CertificateGroups placeholder.
Tested with the NetCore version.
How to reproduce:
Create a server with more than 100 nodes in a single level (for example in a sample server add more variables to Data->Static->Scalar (right now there are 30, add 71 more)
Run Sample Client with System.ArgumentOutOfRangeException' turned on in Visual Studio and observe that the exception is raised in session.Browse function where the continuationPoints.Count exceeds the dimension of the results array (lines 386 onwards).
It is an OPC UA server based on the HistoricalEvents Server in the quickstart. It is running in a linux docker container in .Net core 5.0.
Every time the docker is recreated it will create a new certificate, requiring existing clients to accept the new certificate. I assume that the auto generated certificate logic is using HW information when the server starts to check whether to regenerate the certificate. Meaning my mapped certificate directory for the docker image looks like this.
In addition, as a test the server is deployed in a container instance in Azure with a fixed public IP, and clients complain that the certificate IP/host does not match the public IP, which is correct.
Are we able to disable the auto generation of certificates and tell the server what certificate to use?
Hello everyone,
I'm trying to understand how HistoricalAccess Server Example works. Using UAExpert with Historical Access View I manage to access to some kind of samples saved in .txt files (Boolean.txt, String.txt...) that are inside of "Dynamic" and "Sample" folders. But my goal here is to understand how that files are created or how I can use this kind of Historical Server with my Nodeset2.xml file. Is there some documentation about this HistoricalAccess Server example?
Thanks.
Regards,
André
IOP Workshop 2018 follow up: Issues reported by ITEI with UA Sample Client (.Net 4.6) connecting to reference UA server
The following bugs or unsupported use cases were found on the IOP workshop by GDS users:
We have used the Classic Sample HDA Server(OPCSample.OpcHdaServer)downloaded from the OPC foundation to read the HDA Data But we are not able to read the HDA data when it is connected through AggregationServer
Using KepServer(HDA) successfully we are able to read the HDA data.
Below Error it is throwing
System.Runtime.InteropServices.COMException
HResult=0xC0041001
Message=0xC0041001
Source=
StackTrace:
Hello,
Is there any way, through which I can extract the GDS information model or the address space of this sample server?
Regards,
Rakshan
I am Using Kepserver After restarting(Stop-Start) Services, In UA Expert Address Space it will not display any tags(Nodes) related to Alarm and Events.
**Hi, I'm working with an old version of project downloaded from this github, which still have "UA Quickstart Application.sln".
Here's what I understand:
When I run a Server from this solution, for example, the UserAuthenticaion Server, the Program.cs will call the ServerForm from "opc ua server controls". Then I have to modify the ServerForm to add a function of reading and writing node value from my OPC UA Server (I have done with Client, but I'm trying to add this to the Server).
In ServerForm code, I try to do this:
ReadValueIdCollection list = new ReadValueIdCollection();
DataValueCollection result = new DataValueCollection();
DiagnosticInfoCollection diag = null;
ReadValueId _value = new ReadValueId();
_value.NodeId = new NodeId("ns=2;s=abc2");
list.Add(_value);
m_server.Read(null, 1000, axxxx, list, out result, out diag);
label9.Text = result[0].Value.ToString
(m_server
is defined as Opc.Ua.Server.StandardServer in the original code)
But when I run this code, I think the m_server.Read()
causes error "BadRequestHeaderInvalid" with this line inside UserAuthenticationServer.cs:
It's the same when I trying to write node value.
Can you give me some solution about this? Thank you**
Hi @mregen
Any reason for not upgrading the NetCoreSampleServer and NetCoreSampleClient to Netcore 3.1 (still 2.1) which is LTS at Microsoft?
Regards
I want to add binding in Xamarin Client but it not working
-MainPage.xaml
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:local="clr-namespace:XamarinClient" x:Class="XamarinClient.MainPage" Title="OPC UA Client"> <ContentPage.BindingContext> <local:ConnectionListViewModel/> </ContentPage.BindingContext> <ContentPage.Content> <StackLayout Margin = "20,20,20,20"> <StackLayout VerticalOptions="FillAndExpand" HorizontalOptions="Fill"> <Label Text="OPC UA server's endpoint URL:" FontSize="Medium" TextColor="#0066ff" FontAttributes="Bold"/> <Entry x:Name="EntryUrl" Placeholder="Write your EndpointUrl here" Text="{Binding ConnectionName}"/> <ListView x:Name="ContactsList" ItemsSource="{Binding Connections}" > `
-ConnectionListViewModel:
namespace XamarinClient
{
public class ConnectionListViewModel:INotifyPropertyChanged
{
public ICommand AddConnectionNameCommand => new Command (AddConnectionName);
public ObservableCollection Connections { get; set; }
public string ConnectionName { get; set; }
public string ConnectionUrl { get; set; }
public ConnectionListViewModel()
{
Connections = new ObservableCollection();
Connections.Add("text");
}
public void AddConnectionName()
{
Connections.Add(ConnectionName);
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
[0:] Binding: 'ConnectionName' property not found on 'XamarinClient.ConnectionListViewModel', target property: 'Xamarin.Forms.Entry.Text'
Since this repo contains only samples, the license should be MIT
Hellow.
Now a days I'm trying to learn how is possible to connect the functions of Open/Write/... of my fileState with the buttons of my OPC UA client.
I've studied the case of Alarms where there area a function that create a alarm and then :
AlarmConditionState node = null;
//more code
// set up method handlers.
node.OnEnableDisable = OnEnableDisableAlarm;
node.OnAcknowledge = OnAcknowledge;
node.OnAddComment = OnAddComment;
node.OnConfirm = OnConfirm;
node.OnShelve = OnShelve;
node.OnTimedUnshelve = OnTimedUnshelve;
and also there are the functions private ServiceResult OnAcknowledge(...) that are called when the client click in Acknowledge.
So my question is: How can I conect the Open button with a function? I've tried something like fileState.OnOpen = OnOpen; but there is no option possible. Only something like fileState.Open = new OpenMethodState(fileState); but also its wrong.
Postdata: I'm quite beginner in the OPC UA's world so I appreciate the kindness of everyone :)
hi everyone,
i am using ClearScada server i can see Looping issue for an object in HDA,DA you can see below images
image1 and image2 related to DA .
Image1
.
image1 you can see that is what actually we can see in clearscada
image2
.
image2 you can see objects coming recursively when i connect from uaexpert with underlying server(ClearScada) .
image3 and image4 related to HDA.
image3
.
image3 you can see that is what actually we can see in clearscada .
image4
.
Any help is highly appreciated :)
Hello,
I need some help, please if someone could comment. Basically I can use the wrapper with few items, but when I tried to load more than 500 items, the client just trace timeout's messages. I can´t monitore the items in this case...
If I connect to the Wrapper, browse and start monitoring some items, no problem, and I can added and monitore as much as I can....
But, if I start the OPC UA Client with a saved list (more than 500 items) .... I can´t monitore. I connect, it start and after some time I got a timeout error message.
Am I missing something basic? Please if someone could help i'd appreciate ...
Hi. I'm trying to change server configuration at runtime. But a problem is when i save new configuration into an xml file and reload again. It has error " could not load configuraion file".
This is my form code to change the security Policy of Server
`#region Private Field
private StandardServer m_server;
private ApplicationConfiguration m_configuration;
private ApplicationInstance m_application;
public ServerSecurityPolicy Policy { get; private set; }
#endregion
#region Constructor
public EndpointCtrl()
{
InitializeComponent();
}
#endregion
#region Public Interface
public void Initialize(StandardServer server, ApplicationConfiguration configuration, ApplicationInstance application)
{
m_server = server;
m_configuration = configuration;
m_application = application;
ComboBox adlist = new ComboBox();
foreach (EndpointDescription endpoint in m_server.GetEndpoints())
{
if (adlist.FindStringExact(endpoint.EndpointUrl) == -1)
{
adlist.Items.Add(endpoint.EndpointUrl);
}
}
TCP_Adresss_Label.Text = "(" + adlist.Items[0].ToString() + ")";
HTTPS_Address_Label.Text = "(" + adlist.Items[1].ToString() + ")";
UA_AddressTB.Text = adlist.Items[0].ToString();
HTTPS_AddressTB.Text = adlist.Items[1].ToString();
CheckPolicies(m_configuration);
// m_configuration.ServerConfiguration.BaseAddresses.
}
#endregion
#region Methods
private void CheckPolicies(ApplicationConfiguration configuration)
{
try
{
foreach (ServerSecurityPolicy policy in configuration.ServerConfiguration.SecurityPolicies)
{
if (policy.SecurityMode == MessageSecurityMode.None) UA_SM_NoneCB.Checked = true;
if (policy.SecurityMode == MessageSecurityMode.Sign) UA_SM_SignCB.Checked = true;
if (policy.SecurityMode == MessageSecurityMode.SignAndEncrypt) UA_SM_Sign_EnCB.Checked = true;
if (policy.SecurityPolicyUri == SecurityPolicies.Basic128Rsa15) Basic128Rsa15_CB.Checked = true;
if (policy.SecurityPolicyUri == SecurityPolicies.Basic256) Basic256_CB.Checked = true;
if (policy.SecurityPolicyUri == SecurityPolicies.Basic256Sha256) Basic256Sha256_CB.Checked = true;
}
}
catch (Exception exception)
{
ServerUtils.HandleException(this.Text, exception);
}
}
private void CheckSecurity()
{
try
{
ServerSecurityPolicy policy = new ServerSecurityPolicy();
if (UA_SM_NoneCB.Checked)
{
policy = CreateSecurityPolicy(0, 0);
Addpolicies(m_configuration, policy);
}
else
{
policy = CreateSecurityPolicy(0, 0);
DeletePolicies(m_configuration, policy);
};
if ((UA_SM_SignCB.Checked)&&(Basic128Rsa15_CB.Checked))
{
policy = CreateSecurityPolicy(1, 1);
Addpolicies(m_configuration, policy);
}
else
{
policy = CreateSecurityPolicy(1, 1);
DeletePolicies(m_configuration, policy);
}
if ((UA_SM_Sign_EnCB.Checked)&&(Basic256Sha256_CB.Checked))
{
policy = CreateSecurityPolicy(2, 3);
Addpolicies(m_configuration, policy);
}
else
{
policy = CreateSecurityPolicy(2, 3);
DeletePolicies(m_configuration, policy);
}
}
catch (Exception exception)
{
ServerUtils.HandleException(this.Text, exception);
}
}
private void Addpolicies(ApplicationConfiguration configuration, ServerSecurityPolicy polici)
{
try
{
int i = 0;
foreach (ServerSecurityPolicy policy in configuration.ServerConfiguration.SecurityPolicies)
{
if (polici == policy) i++;
}
if (i == 0) configuration.ServerConfiguration.SecurityPolicies.Add(polici);
}
catch (Exception exception)
{
ServerUtils.HandleException(this.Text, exception);
}
}
private void DeletePolicies(ApplicationConfiguration configuration, ServerSecurityPolicy polici)
{
try
{
int i = 0;
foreach (ServerSecurityPolicy policy in configuration.ServerConfiguration.SecurityPolicies)
{
if (polici == policy) configuration.ServerConfiguration.SecurityPolicies.Add(policy);
break;
}
}
catch (Exception exception)
{
ServerUtils.HandleException(this.Text, exception);
}
}
private ServerSecurityPolicy CreateSecurityPolicy(byte MessageMode, byte PolicyNumber)
{
try
{
ServerSecurityPolicy Policy = new ServerSecurityPolicy();
switch (MessageMode)
{
case 0:
Policy.SecurityMode = MessageSecurityMode.None;
break;
case 1:
Policy.SecurityMode = MessageSecurityMode.Sign;
break;
case 2:
Policy.SecurityMode = MessageSecurityMode.SignAndEncrypt;
break;
default:
Policy.SecurityMode = MessageSecurityMode.Invalid;
break;
}
switch (PolicyNumber)
{
case 0:
Policy.SecurityPolicyUri = SecurityPolicies.None;
break;
case 1:
Policy.SecurityPolicyUri = SecurityPolicies.Basic128Rsa15;
break;
case 2:
Policy.SecurityPolicyUri = SecurityPolicies.Basic256;
break;
case 3:
Policy.SecurityPolicyUri = SecurityPolicies.Basic256Sha256;
break;
}
}
catch (Exception exception)
{
ServerUtils.HandleException(this.Text, exception);
}
return Policy;
}
#endregion
#region Event Hanlder
#endregion
private void ApplyBtn_Click(object sender, EventArgs e)
{
try
{
CheckSecurity();
m_configuration.SaveToFile(m_application.ConfigSectionName + ".Config.xml");
m_application.LoadApplicationConfiguration(false);
}
catch (Exception exception)
{
ServerUtils.HandleException(this.Text, exception);
}
}
}
}`
I save this but when I Click apply setting to change the config and reload the server configuration. It has error
Why is this happen??? Is any solution to solve this. Thank you.
Though I have code CheckPermission but after that I can't connected to server- made from Prosys OPC UA Simulation Server. And WARNING "cannot connect to an OPC UA server"
I should call the method: "GenerateFileForRead".
The problem is that I don't know how to set the Input Parameter which I should pass to the method
When I Use the UaExpert and call this method:
I see the method wants a "ProductionDatasetReadOptionsType but I don't know how get it to modifiy as in the picture above
I know its node Id but but how derive the type from it?
Anybody can help me?
Hi friends,
Can you please guide me the correct steps/sequence to run an OPC UA Server with reverse connection and connect an OPC UA Client with reverse connection. I badly need it for my work to complete. Please guide me on which project to build and run first followed by the other. Basically the sequence. Also please do guide me on any hacks or extra steps to be taken care for reverse connection to work.
Please also guide me on what exactly needs to be passed to the reverse connection manager URI. and also the Server uri. I am getting confusion over this in the OPC Client with reverse connection. An example if you can provide will be awsome.
Thanks & Regards
Aravind S.
Type of Issue
[ ] Bug [ ] Enhancement [ ] Compliance [x ] Question [ ] Help wanted
Hi, I have 2 hosts. Host A and Host B.
Host A has the .net core GDS running (as it is on Linux). Also it has an LDS(mDNS enabled) .
Next, I have the HostB(Windows), which has its local discovery service running in the background, and also a prosys simulation server registered to it. I run the global discovery client here.
Using the select GDS, I connect to the GDS running on host A.
Now, the observation is that in the discovery section -> on the local machine-> I observe the prosys simulation server
on the local network-> I observe the LDS of hostA, and Prosys server(HostB)
on the global discovery-> empty
But on the global discovery, I expect it to show the above mentioned servers in the list. But it shows an empty list. Should it not show the cumulative list of all the servers?
Could you please guide me as to what am I doing wrong here?
Also, one more question is: In the tutorial video, a sample config file of a server was registered to the GDS client(server pull). And it was shown in the global discovery section. Now, is it a step to be taken when there is no LDS in the system like in Intro
Or was that step, the 2nd step in the GDS Overview
Extremely confused.. Look forward for some guidance here
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.