Avatar
Please consider registering
guest
sp_LogInOut Log Insp_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 RSSsp_TopicIcon
How to graciously abort a uaClient.connect() before the timeout
August 19, 2019
12:22, EEST
Avatar
hbrackel
Member
Members
Forum Posts: 144
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: 1045
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: 1029
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: 144
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: 1029
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: 1919
Currently Online:
Guest(s) 13
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 90
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 733
Moderators: 8
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1545
Posts: 6516
Newest Members:
ptdenriqueta, basilpullman, Richardmip, mood edibles, LouieWreve, daniellabdx, janessan21, sammiebeak359, gena7127517, thorstenbouldin
Moderators: Jouni Aro: 1029, Pyry: 1, Petri: 1, Bjarne Boström: 1045, Jimmy Ni: 26, Matti Siponen: 353, Lusetti: 0, Elias: 0
Administrators: admin: 1