Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Simple UA server not working (not showing anything in Prosys OPC UA Client tool)
September 6, 2018
23:27, EEST
Avatar
Colin Bennett
Member
Members
Forum Posts: 5
Member Since:
September 6, 2018
sp_UserOfflineSmall Offline

We are evaluating the Prosys OPC UA Java SDK for our current project. The first task is to create an OPC server application that simply serves up a single object, in this case we are going to use the current system time.

But after following the Prosys OPC UA Java Server Tutorial PDF instructions, and creating an app that should provide a “MyLevel” object via OPC, the client does not seem able to connect or perhaps not able to browse.

Is there something we are missing?

Here is the Java application, which runs on OPC TCP port 52123.

package com.den.opcuaservertest;

import com.prosysopc.ua.*;
import com.prosysopc.ua.UaApplication.Protocol;
import com.prosysopc.ua.nodes.UaObject;
import com.prosysopc.ua.nodes.UaObjectType;
import com.prosysopc.ua.nodes.UaType;
import com.prosysopc.ua.nodes.UaVariable;
import com.prosysopc.ua.server.*;
import com.prosysopc.ua.server.nodes.CacheVariable;
import com.prosysopc.ua.server.nodes.UaObjectNode;
import com.prosysopc.ua.server.nodes.UaObjectTypeNode;
import com.prosysopc.ua.types.opcua.server.FolderTypeNode;
import org.opcfoundation.ua.builtintypes.LocalizedText;
import org.opcfoundation.ua.builtintypes.NodeId;
import org.opcfoundation.ua.core.*;

import java.io.File;
import java.io.IOException;
import java.util.Locale;

public class Main {
    public static void main(String[] args) {
        try {
            UaServer server = new UaServer();

            String APP_NAME = "opcuaservertest";
            ApplicationDescription appDescription = new ApplicationDescription(); // 'localhost' (all lower case) in the ApplicationName and
            // ApplicationURI is converted to the actual host name of the computer
            // in which the application is run
            appDescription.setApplicationName(new LocalizedText(APP_NAME + "@localhost"));
            appDescription.setApplicationUri("urn:localhost:OPCUA:" + APP_NAME);
            appDescription.setProductUri("urn:enelx.com:OPCUA:" + APP_NAME);
            appDescription.setApplicationType(ApplicationType.Server);

            // Use 0 to use the default keySize and default file names (for other // values the file names will include the key size.
            int[] keySizes = new int[]{0, 4096};

            // Define the client application identity, including the security // certificate
            final ApplicationIdentity identity = ApplicationIdentity
                    .loadOrCreateCertificate(
                            appDescription,
                            "Sample Organisation",
                            /* Private Key Password */"opcua",
                            /* Key File Path */new File("private-keys"),
                            /* CA certificate & private key */ null,
                            /* Key Sizes for instance certificates to create */keySizes,
                            /* Enable renewing the certificate */true);

            server.setApplicationIdentity(identity);

            // TCP Port number for the UA Binary protocol
            server.setPort(Protocol.OpcTcp, 52123);
            // TCP Port for the HTTPS protocol
            server.setPort(Protocol.Https, 52443);
            server.setServerName("MyTestServer");

            server.addUserTokenPolicy(UserTokenPolicy.ANONYMOUS);
            server.addUserTokenPolicy(UserTokenPolicy.SECURE_USERNAME_PASSWORD);
            server.addUserTokenPolicy(UserTokenPolicy.SECURE_CERTIFICATE);
            server.setUserValidator(new MyUserValidator());

            System.out.println("Initializing server...");
            server.init();

            NodeManagerUaNode myNodeManager = new NodeManagerUaNode(server, "http://www.enernoc.com/opcua/test");
            int ns = myNodeManager.getNamespaceIndex();
            final UaObject objectsFolder = server.getNodeManagerRoot().getObjectsFolder();
            final UaType baseObjectType = server.getNodeManagerRoot().getType(Identifiers.BaseObjectType);
            final UaType baseDataVariableType = server.getNodeManagerRoot().getType(Identifiers.BaseDataVariableType);

            // Folder for my objects
            final NodeId myObjectsFolderId = new NodeId(ns, "MyObjectsFolder");
            FolderTypeNode myObjectsFolder = myNodeManager.createInstance(FolderTypeNode.class, "MyObjects", myObjectsFolderId);
            myNodeManager.addNodeAndReference(objectsFolder, myObjectsFolder, Identifiers.Organizes);

            // My Device Type
            // The preferred way to create types is to use Information Models, but this example shows how // you can do that also with your own code
            final NodeId myDeviceTypeId = new NodeId(ns, "MyDeviceType");
            UaObjectType myDeviceType = new UaObjectTypeNode(myNodeManager, myDeviceTypeId, "MyDeviceType", Locale.ENGLISH);
            myNodeManager.addNodeAndReference(baseObjectType, myDeviceType, Identifiers.HasSubtype);
            // My Device
            final NodeId myDeviceId = new NodeId(ns, "MyDevice");
            UaObject myDevice = new UaObjectNode(myNodeManager, myDeviceId, "MyDevice", Locale.ENGLISH);
            myDevice.setTypeDefinition(myDeviceType);
            myObjectsFolder.addReference(myDevice, Identifiers.HasComponent, false);

            // My Level Type
            final NodeId myLevelTypeId = new NodeId(ns, "MyLevelType");
            UaType myLevelType = myNodeManager.addType(myLevelTypeId, "MyLevelType", baseDataVariableType);
            // My Level Measurement
            final NodeId myLevelId = new NodeId(ns, "MyLevel");
            UaType doubleType = myNodeManager.getServer().getNodeManagerRoot().getType(Identifiers.Double);
            UaVariable myLevel = new CacheVariable(myNodeManager, myLevelId, "MyLevel", LocalizedText.NO_LOCALE);
            myLevel.setDataType(doubleType);
            myLevel.setTypeDefinition(myLevelType);
            myDevice.addComponent(myLevel);

            System.out.println("Starting server...");
            server.start();
            System.out.println("Server started.");
        } catch (UaServerException | SecureIdentityException | IOException | StatusException e) {
            e.printStackTrace();
        }
    }

    private static class MyUserValidator implements UserValidator {
        @Override
        public boolean onValidate(Session session, ServerUserIdentity serverUserIdentity) throws StatusException {
            // Note that the UserIdentity can be of different actual types,
            // depending on the selected authentication mode (by the client).
            System.out.println("onValidate: userIdentity=" + serverUserIdentity);
            if (serverUserIdentity.getType().equals(UserTokenType.UserName)) {
                return serverUserIdentity.getName().equals("opcua")
                        && serverUserIdentity.getPassword().equals("opcua");
            }
            if (serverUserIdentity.getType().equals(UserTokenType.Certificate)) {
                // Implement your strategy here, for example using the PkiFileBasedCertificateValidator
                return true;
            }
            return true;
        }

        @Override
        public void onValidationError(Session session, UserIdentityToken userIdentityToken, Exception e) {
            System.err.println("Validation error for user credentials");
            e.printStackTrace(System.err);
        }
    }

}
September 7, 2018
10:21, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

The tutorial documents follows most of the code in the SampleConsoleClient and SampleConsoleServer samples that are in the ‘samples’ folder of the SDK package. I recommend first setting up a development environment and running both of them (with the SampleConsoleClient connecting to the SampleConsoleServer), please read the Prosys_OPC_UA_Java_SDK_Starting_Guide.pdf next to the client and server tutorials.

September 7, 2018
11:23, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1026
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

I agree with Bjarne, that it is best to start with the samples, and apparently you have done so, since you have copied the base of your server from the sample.

The most probable reason is that you are not using the correct connection address to the server. When you are defining ServerName=’MyTestServer’, your connection address is ‘opc.tcp://localhost:52123/MyTestServer’

If you are connecting to ‘opc.tcp://localhost:52123’, you will actually connect to an internal discovery server, which is only capable of responding to the GetEndpoints service requests.

I recommend that you set up log4j logging for your project as well: you should then see the connection addresses printed out by the server INFO level.

September 7, 2018
21:13, EEST
Avatar
Colin Bennett
Member
Members
Forum Posts: 5
Member Since:
September 6, 2018
sp_UserOfflineSmall Offline

Bjarne and Jouni,
Thanks for the replies.

I did enable Log4J now, and I ensured I used the full URL with “/MyTestServer”. In fact, if I omit the “/MyTestServer” path, the OPC UA client GUI automatically adds it for me.

The GUI client continues to show “Disconnected” on the left of the URL even once it appears to have connected, and the object tree (below “Search”) is blank.

Yes, if I use the “sampleconsoleserver” app it does work. But that uses a BigNodeManager, which as I understand it, is not the normal and simple use case. I tried copying the server initialization code from sampleconsoleserver into my test app, but it made no difference. I was hoping for a simple, common case example we could use as a starting point for our application. Do you have any other examples of a UA server?

Here is the log4j output when I start my server app, then connect with the Prosys UA client. I set log4j to INFO since DEBUG was too verbose:

* Prosys OPC UA Java SDK v3.1.4-514
* (c) Prosys OPC Ltd. 

* Running in EVALUATION mode
* Connections will close after 119 minutes

INFO  ApplicationIdentity - Reading application certificate from /Users/colin.bennett/IdeaProjects/ftm2/private-keys/MyTestServer@COLIBENN-MBP1.der
INFO  ApplicationIdentity - Reading private key from keystore /Users/colin.bennett/IdeaProjects/ftm2/private-keys/MyTestServer@COLIBENN-MBP1.pem
INFO  CryptoUtil - SecurityProvider initialized from org.bouncycastle.jce.provider.BouncyCastleProvider
INFO  CryptoUtil - Using SecurityProvider BC
INFO  ApplicationIdentity - Reading application certificate from /Users/colin.bennett/IdeaProjects/ftm2/private-keys/MyTestServer@COLIBENN-MBP1_4096.der
INFO  ApplicationIdentity - Reading private key from keystore /Users/colin.bennett/IdeaProjects/ftm2/private-keys/MyTestServer@COLIBENN-MBP1_4096.pem
Initializing server...
INFO  NodeManagerTable - Loading model from jar:file:/Users/colin.bennett/IdeaProjects/opcua-server-test/lib/prosys-opc-ua-java-sdk-client-server-evaluation-3.1.4-514.jar!/com/prosysopc/ua/types/opcua/server/Opc.Ua.NodeSet2.xml
WARN  XMLFactoryCache - Cannot initialize XML factories to ignore DTD processing, please update java to newer version
Starting server...
INFO  UaServer - Server endpoint: https://COLIBENN-MBP1.local:52443/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None]]
INFO  HttpsServer - Enabled protocols in SSL Engine are [SSLv2Hello, TLSv1, TLSv1.1, TLSv1.2]
INFO  HttpsServer - Enabled CipherSuites in SSL Engine are [TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
INFO  HttpsServer - CipherSuites for policies (null) are [TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256]
INFO  HttpsServer - Endpoint bound to https://COLIBENN-MBP1.local:52443/MyTestServer
INFO  HttpsServer - Endpoint bound to https://COLIBENN-MBP1.local:52443
INFO  HttpsServer - Endpoint bound to https://COLIBENN-MBP1.local:52443/MyTestServer
INFO  HttpsServer - Endpoint bound to https://COLIBENN-MBP1.local:52443
INFO  UaServer - Endpoint bound to: [10.92.2.141:52443, 127.0.0.1:52443]
INFO  UaServer - Server endpoint: opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]
INFO  OpcTcpServer - TCP/IP Socket bound to /10.92.2.141:52123
INFO  OpcTcpServer - TCP/IP Socket bound to /127.0.0.1:52123
INFO  UaServer - Endpoint bound to: [10.92.2.141:52123, 127.0.0.1:52123]
Server started.
INFO  OpcTcpServer - OpcTcpServer(opc.tcp(/10.92.2.141:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))opc.tcp(/127.0.0.1:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))): /10.92.2.141:62740 connected
INFO  OpcTcpServerSecureChannel - SecureChannel opened; SecurityToken(Id=1, secureChannelId=1, creationTime=Sep 7, 2018 11:13:24 AM, lifetime=3600000)
INFO  OpcTcpServerSecureChannel - Secure Channel closed, token=SecurityToken(Id=1, secureChannelId=1, creationTime=Sep 7, 2018 11:13:24 AM, lifetime=3600000)
INFO  AbstractServerSecureChannel - Channel closed: Id=1
INFO  OpcTcpServer - OpcTcpServer(opc.tcp(/10.92.2.141:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))opc.tcp(/127.0.0.1:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))): /10.92.2.141:62741 connected
INFO  OpcTcpServerSecureChannel - SecureChannel opened; SecurityToken(Id=1, secureChannelId=2, creationTime=Sep 7, 2018 11:13:24 AM, lifetime=3600000)
INFO  AsyncSocketImpl - AsyncSocketInputStream.close(): unexpected untriggered monitor
INFO  OpcTcpServerSecureChannel - Secure Channel closed, token=SecurityToken(Id=1, secureChannelId=2, creationTime=Sep 7, 2018 11:13:24 AM, lifetime=3600000)
INFO  AbstractServerSecureChannel - Channel closed: Id=2
INFO  OpcTcpServer - OpcTcpServer(opc.tcp(/10.92.2.141:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))opc.tcp(/127.0.0.1:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))): /10.92.2.141:62742 connected
INFO  OpcTcpServerSecureChannel - SecureChannel opened; SecurityToken(Id=1, secureChannelId=3, creationTime=Sep 7, 2018 11:13:24 AM, lifetime=3600000)
INFO  AsyncSocketImpl - AsyncSocketInputStream.close(): unexpected untriggered monitor
INFO  OpcTcpServerSecureChannel - Secure Channel closed, token=SecurityToken(Id=1, secureChannelId=3, creationTime=Sep 7, 2018 11:13:24 AM, lifetime=3600000)
INFO  AbstractServerSecureChannel - Channel closed: Id=3
INFO  OpcTcpServer - OpcTcpServer(opc.tcp(/10.92.2.141:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))opc.tcp(/127.0.0.1:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))): /10.92.2.141:62743 connected
INFO  OpcTcpServerSecureChannel - SecureChannel opened; SecurityToken(Id=1, secureChannelId=4, creationTime=Sep 7, 2018 11:13:24 AM, lifetime=3600000)
INFO  AsyncSocketImpl - AsyncSocketInputStream.close(): unexpected untriggered monitor
INFO  OpcTcpServerSecureChannel - Secure Channel closed, token=SecurityToken(Id=1, secureChannelId=4, creationTime=Sep 7, 2018 11:13:24 AM, lifetime=3600000)
INFO  AbstractServerSecureChannel - Channel closed: Id=4
INFO  OpcTcpServer - OpcTcpServer(opc.tcp(/10.92.2.141:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))opc.tcp(/127.0.0.1:52123, (opc.tcp://COLIBENN-MBP1.local:52123 [[http://opcfoundation.org/UA/SecurityPolicy#None,None]])(opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer [[http://opcfoundation.org/UA/SecurityPolicy#None,None], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15,SignAndEncrypt], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,Sign], [http://opcfoundation.org/UA/SecurityPolicy#Basic256,SignAndEncrypt]]))): /10.92.2.141:62744 connected
INFO  OpcTcpServerSecureChannel - SecureChannel opened; SecurityToken(Id=1, secureChannelId=5, creationTime=Sep 7, 2018 11:13:25 AM, lifetime=3600000)
INFO  SessionManager - Session created: ProsysOpcUaClient Session9 (ID=ns=1;g=1c51b00a-1012-4500-a9a7-d7105bd5e62d Token=i=3040671780 Channel=(SecureChannelId=5 State=Open URL=opc.tcp://COLIBENN-MBP1.local:52123/MyTestServer SecurityPolicy=http://opcfoundation.org/UA/SecurityPolicy#None RemoteAddress=/10.92.2.141:62744))
September 10, 2018
11:04, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Did a test run with that code. I could reproduce the issue few times.

Most likely it is because of int[] keySizes = new int[]{0, 4096};. If you can use int[] keySizes = null; (i.e. it will create only one cert with the default size; this is also the default in SampleConsoleServer) it should work.

We fixed some issues in 3.1.6 related to server having multiple certs, https://downloads.prosysopc.com/opcua/release_notes3.1.6-542.html. However apparently something is still not right, since I could reproduce the issue with it (using None mode).

You can ignore the MyBigNodeManager if you want (e.g. comment out in SampleConsoleServer.createAddressSpace), most of the code you have in the original post are in the MyNodeManager class in that sample.

While I somewhat agree that the SampleConsoleServer example with all of it’s classes is a bit complicated at first, most of the things there you will anyway need in a fully functioning opc ua server (certs, users, etc.). We should maybe do some refactoring for it in the future or see if we can come up with a more simpler example.

September 10, 2018
16:47, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 1026
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

This happens because server defines 2 certs, and for both the endpoint for security mode None is created. Then our client side will select one of them (the later in the list returned by the server in GetEndpointsResponse) and in practice the server does not know which one since the thumprint is not sent on None connections and the server defaulted returning the first cert in CreateSessionResponse (which is a mismatch, the current version of the grapchical client fails to report this error).

Future SDK versions will skip this check on None security mode avoiding the issue.

September 12, 2018
19:03, EEST
Avatar
Colin Bennett
Member
Members
Forum Posts: 5
Member Since:
September 6, 2018
sp_UserOfflineSmall Offline

Thanks, Bjarne. Setting the keySizes array to null fixed the problem.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 1919

Currently Online:
28 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Heikki Tahvanainen: 402

hbrackel: 144

rocket science: 88

pramanj: 86

Francesco Zambon: 83

Ibrahim: 78

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

Member Stats:

Guest Posters: 0

Members: 737

Moderators: 7

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1524

Posts: 6450

Newest Members:

fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley

Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0

Administrators: admin: 1