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
cigerxwinchaker@hotmail.com
Member
Members
Forum Posts: 7
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: 801
Member Since:
April 3, 2012
sp_UserOnlineSmall Online

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
cigerxwinchaker@hotmail.com
Member
Members
Forum Posts: 7
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: 801
Member Since:
April 3, 2012
sp_UserOnlineSmall Online

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
cigerxwinchaker@hotmail.com
Member
Members
Forum Posts: 7
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: 801
Member Since:
April 3, 2012
sp_UserOnlineSmall Online

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: 267

Currently Online: Bjarne Boström
5 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 120

pramanj: 86

ibrahim: 74

rocket science: 65

kapsl: 57

gjevremovic: 49

Sabari: 44

Xavier: 42

fred: 41

TimK: 41

Member Stats:

Guest Posters: 0

Members: 3125

Moderators: 17

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1277

Posts: 5457

Newest Members:

felisharedden25, valentinanoblet, XNXXguini, RobertTop, baileyuup3516, Richardlacle, inezwb11, clarissabeasley, raulakhtar528, claritanisbett4

Moderators: Jouni Aro: 942, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 801, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 25, Teppo Uimonen: 21, Markus Johansson: 41, Niklas Nurminen: 0, Matti Siponen: 209, Lusetti: 0

Administrators: admin: 1