07/29/2019
Hi ,
I want to implement an OPCUA client in .net . I would like to find out how OPC UA client are communicating with server and reading the response.
At first I started the client only but unable to connect to OPC UA server “opc.tcp://212.43.72.27:51510/UA/WipotecServer/”.
Sample Code s are here
AppSession.UserIdentity = new UserIdentity();
AppSession.SessionName = “urn:ACGIDT053:UnifiedAutomation:UaExpert”;
//string endpointUrl = “opc.tcp://212.43.72.27:51510/UA/WipotecServer/”;
AppSession.Connect(endpointUrl, SecuritySelection.None);
ICertificate certificateServer = SecurityUtils.LoadCertificate(AppSession.EndpointDescription.ServerCertificate);
AppSession.Application.TrustedStore.Add(certificateServer, true);
/// [Step 1]
// parse the object id.
NodeId objectId = NodeId.Parse(“ns=2;i=15108”);
// get the selected method id.
NodeId methodId = NodeId.Parse(“ns=2;i=15057”);
// get input arguments.
UInt32 a = 2;
//List inputArguments = new List
//{
// new Variant(string.Empty, TypeInfo.Scalars.String), new Variant(a,TypeInfo.Scalars.UInt32), new Variant(string.Empty, TypeInfo.Scalars.String),
// new Variant(null, TypeInfo.Arrays.ExtensionObject), new Variant(string.Empty, TypeInfo.Scalars.String)
//};
List ar = new List();
List inputArguments = new List
{
new Variant(string.Empty, TypeInfo.Scalars.String), new Variant(a,TypeInfo.Scalars.UInt32), new Variant(string.Empty, TypeInfo.Scalars.String),
new Variant(ar.ToArray(), TypeInfo.Arrays.ExtensionObject), new Variant(string.Empty, TypeInfo.Scalars.String)
};
/// [Step 2]
List inputArgumentErrors;
List outputArguments = null;
// call the method on the server.
StatusCode error = AppSession.Call(
objectId,
methodId,
inputArguments,
out inputArgumentErrors,
out outputArguments);
I would appreciate if anyone will help me to understand the connectivity part between client and server or sample .net code
thanks
05/30/2017
The server appears to be very slow so timeouts during connect could be occurring.
Add the certificate to the trustlist after successful connection does not help.
You need to add a handler for an untrusted certificate (should be an event on the Session object),
You also need to set whatever option is there to use the domain from the URL since the server returns a different domain that may not be accessible and the Connect method uses this domain by default.
Wireshark is a useful tool for monitoring network traffic. There is a plugin for OPC UA messages which is part of the standard distribution.
07/29/2019
Hello,
I’m developing OPEN SCS client application in .net using .net SDK.
we have completed Following steps.
- POC is ready to connect to Wipotec Test Server opc.tcp://212.43.72.27:51510/UA/WipotecServer/
- Able to connect to Wipotec test server
- In response we always receiving the zero
I did check for response , im getting same response with certificate and without certificate.
I did not understand above answer , could you please modify the code and share with me or some sampe code or url?
1.
string endpointUrl = “opc.tcp://212.43.72.27:51510/UA/WipotecServer/”;
OPENSCS_Library.OPENSCS_Library openscsLibrary = new OPENSCS_Library.OPENSCS_Library();
openscsLibrary.Connect(endpointUrl);
2.
ApplicationInstance AppInstance = ApplicationInstance.Default;
Session AppSession = new Session();
3.
AppSession.UserIdentity = new UserIdentity();
// for Anonymous
AppSession.UserIdentity.IdentityType = UserIdentityType.Anonymous;
AppSession.SessionName = “urn:ACGIDT053:UnifiedAutomation:UaExpert”;
AppSession.UseDnsNameAndPortFromDiscoveryUrl = true;
AppSession.Connect(endpointUrl, SecuritySelection.None);
ICertificate certificateServer = SecurityUtils.LoadCertificate(AppSession.EndpointDescription.ServerCertificate);
AppSession.Application.TrustedStore.Add(certificateServer, true);
/// [Step 1]
// parse the object id.
NodeId objectId = NodeId.Parse(“ns=2;i=108”);
// get the selected method id.
NodeId methodId = NodeId.Parse(“ns=2;i=57”);
//NodeId objectId = NodeId.Parse(“ns=2;i=15108”);
//// get the selected method id.
//NodeId methodId = NodeId.Parse(“ns=2;i=15057”);
// get input arguments.
UInt32 a = 2;
List<Variant> inputArguments = new List<Variant>
{
new Variant(string.Empty, TypeInfo.Scalars.String), new Variant(a,TypeInfo.Scalars.UInt32), new Variant(string.Empty, TypeInfo.Scalars.String),
new Variant(null, TypeInfo.Arrays.ExtensionObject), new Variant(string.Empty, TypeInfo.Scalars.String)
};
/// [Step 2]
List<StatusCode> inputArgumentErrors;
List<Variant> outputArguments = null;
// call the method on the server.
StatusCode error = AppSession.Call(
objectId,
methodId,
inputArguments,
out inputArgumentErrors,
out outputArguments);
List<ReadValueId> readListIds = new List<ReadValueId>();
readListIds.Add(new ReadValueId { NodeId = NodeId.Parse(“ns=2;i=57”) });
List<DataValue> dataValues = AppSession.Read(readListIds);
1 Guest(s)