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
Why is my Application "paused" or "parked"?
August 5, 2022
10:31, EEST
Avatar
CC
Member
Members
Forum Posts: 8
Member Since:
August 4, 2022
sp_UserOfflineSmall Offline

My Program is executing until it ends in the “park” function. I wonder why.

. I have the following Code: It wont reach the System.out.println(value);

public static void main(String[] args) throws Exception {
UaClient client = new UaClient(“opc.tcp://10.113.172.210:16664”);
client.setSecurityMode(SecurityMode.BASIC128RSA15_SIGN_ENCRYPT);
initialize(client);
client.connect();
DataValue value = client.readValue(Identifiers.Server_ServerStatus_State);
System.out.println(value);
client.disconnect();
}

protected static void initialize(UaClient client) throws SecureIdentityException, IOException, UnknownHostException {
// *** Application Description is sent to the server
ApplicationDescription appDescription = new ApplicationDescription();
appDescription.setApplicationName(new LocalizedText(“Simple” + “@localhost”));
appDescription.setApplicationUri(“urn:localhost:OPCUA:” + “Simple”);
appDescription.setProductUri(“urn:prosysopc.com:UA:Simple”);
appDescription.setApplicationType(ApplicationType.Client);
final PkiDirectoryCertificateStore certStore = new PkiDirectoryCertificateStore();
File privatePath = new File(certStore.getBaseDir(), “private”);
int certKeySize = 2048;
int[] keySizes = new int[] {certKeySize};

final ApplicationIdentity identity = ApplicationIdentity.loadOrCreateCertificate(appDescription,
“kisters”, /* Private Key Password, optional */”opcua”, /* Key File Path */privatePath,
/* CA certificate & private key, optional */null,
/* Key Sizes for instance certificates to create, optional */keySizes,
/* Enable renewing the certificate */true);

client.setApplicationIdentity(identity);

identity.setApplicationDescription(appDescription);
}

August 8, 2022
9:50, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

If you use a security mode other than NONE (i.e. you use BASIC128RSA15_SIGN_ENCRYPT here), then each application (client and the server) must trust each-others certificate. This probably would require a better tutorial as this is asked somewhat often, but basically if you use the full sampleconsoleclient, the MyCertificateValidationListener would ask do you want to trust the server certificate. Please note that this only resolves the client side, the server must also trust the client’s certificate. How to do that depends on the server. Based on the connection uri you have specified, I would assume the server is not our sampleconsoleserver, thus I do not know how you would do that on the server, typically there is some UI or filesystem-based option.

Anyway, with no listener defined on the client side you would put the server’s applicationinstancecertificate’s public key to the PKI/CA/certs, or after you have tried once with it failing it would be stored in the ‘rejected’ folder next to the ‘certs’ and could be moved from there (please note that if you leave it both in ‘certs’ and ‘rejected’ it will be treated as rejected, thus move and not copy).

August 9, 2022
10:09, EEST
Avatar
CC
Member
Members
Forum Posts: 8
Member Since:
August 4, 2022
sp_UserOfflineSmall Offline

@Bjarne Boström

Actually my Application will connect to the Server but it takes too much time to get a response.

August 9, 2022
15:10, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

How long is “too much time” here? Seconds? Minutes? Hours?? How fast would be fast enough? I can make a longer reply once I know that, but note that with defaults UaClient.connect does also read/browse stuff regarding the types and metadata needed for custom structures, i.e. it is normal if it takes like a few seconds. If the server is behind a slow connection or uses low-power hardware it might take 10s of seconds.

There are flags to control this a bit, but it depends a bit on what you need and how you use the SDK. Also it is a bit more typical that the connections to last forever once connected than “a connect do stuff and then disconnect”-case so there are different things to optimize, our defaults might not be what you want, but I’ll need to know a bit more to say a better answer.

August 10, 2022
11:12, EEST
Avatar
CC
Member
Members
Forum Posts: 8
Member Since:
August 4, 2022
sp_UserOfflineSmall Offline

@Bjarne Boström
It takes about 2 minutes to execute this function client.connect();

So i dont know why this is taking that much time. After this it is connected and reads the Value
DataValue value = client.readValue(Identifiers.Server_ServerStatus_State);
correctly

All i want for now is to read certain Values. Later i want to subscribe to a (maybe big) amount of Datavalues.

August 10, 2022
15:55, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 983
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

If you do not need to resolve i.e. read/write custom Structures (if you see ExtensionObject instances ever then you have encountered one as normally the SDK will automatically decode them), then the following should help:

client.setInitTypeDictionaryAutoUsage(false)
client.setInitTypeDictionaryOnConnect(false)

(call before calling connect)

In addition if they are false the first interaction with any type directly or indirectly via UaNodes e.g. client.getAddressSpace().getNode(…) is slower (how much will depend on the network and the server, the current defaults and logic exist because this has been a problem in the past in some cases). The UaNodes help quite a bit if you need to Browse as they model the nodes on the server and you can e.g. ask references from them directly (or cast them to known types etc.).

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
28 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

Ibrahim: 76

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 681

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6261

Newest Members:

graciela2073, sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com

Moderators: Jouni Aro: 1010, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1