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
How to graciously abort a uaClient.connect() before the timeout
August 19, 2019
12:22, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 135
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

Good morning,

I have multiple OPC UA clients trying to connect to various OPC UA services (aka servers). In case any of the OPC UA servers does not respond, the corresponding UaClient.connect() calls *eventually* timeout (after the configured period).

Is there a way to prematurely graciously abort the client.connect() attempt? Are there any differences between the SDK versions 3.1.6 and 4.x?

Thanks,
Hans-Uwe

August 20, 2019
11:24, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 982
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

Hi,

Not exactly at the moment. 4.0.0 added UaClient.setConnectTimeout(…), which makes easier to set the initial connection (i.e. Socket gets initial connection) timeout. Maybe you could start with quite optimistic timeout first and then increase it if a connect fails due to that?

August 20, 2019
13:26, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

You can also consider running the connect method in a worker thread so that your application doesn’t need to block and wait for the call to timeout if it takes too long.

At some point we considered adding a separate connectAsync method for that, but it turned out to be very complex – especially in comparison to how simple it is to do it yourself in a worker three suitable to your application.

August 20, 2019
13:49, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 135
Member Since:
February 21, 2014
sp_UserOfflineSmall Offline

We have remote servers over a high latency connection – so the timeout length is indeed needed. Sometimes though, the address of the server has been incorrectly configured and the new configuration shall be picked up as quickly as possible.
The connect() attempt is already running in a worker thread. While terminating the worker thread is possible, this would be “brute force” and eventually leave some resources in an undefined state – which I’d prefer to avoid.

August 20, 2019
15:39, EEST
Avatar
Jouni Aro
Moderator
Moderators
Forum Posts: 1009
Member Since:
December 21, 2011
sp_UserOfflineSmall Offline

Yes, that can be a bit tricky. I would say that it’s best to use the new ConnectTimeout for this.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
16 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 708

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1465

Posts: 6252

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

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

Administrators: admin: 1