Unable to connect from OPC UA client developed in .net to OPC US server|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Unable to connect from OPC UA client developed in .net to OPC US server
Avatar
Sanjay Yadav
New Member
Members
Forum Posts: 2
Member Since:
07/29/2019
sp_UserOfflineSmall Offline
1
08/24/2019 - 10:45
sp_Permalink sp_Print sp_EditHistory

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

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOnlineSmall Online
2
08/27/2019 - 11:31
sp_Permalink sp_Print

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.

Avatar
Sanjay Yadav
New Member
Members
Forum Posts: 2
Member Since:
07/29/2019
sp_UserOfflineSmall Offline
3
08/30/2019 - 06:14
sp_Permalink sp_Print

Hello,

I’m developing OPEN SCS client application in .net using .net SDK.

 

we have completed Following steps.

  1. POC is ready to connect to Wipotec Test Server opc.tcp://212.43.72.27:51510/UA/WipotecServer/
  2. Able to connect to Wipotec test server
  3. 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);

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online: Randy Armstrong
Guest(s) 58
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1445
Posts: 4889