Client can't reconnect to session

77 views
Skip to first unread message

Stamatis Poulios

unread,
Jun 25, 2021, 5:57:50 AM6/25/21
to open62541
Hi all.

I will try to explain the situation I am facing, hoping someone will give me a hint.

I have a client (open62541) which connects to a server (Unified Automation), using "UA_Client_connectUsername()" function.

Periodically, the client reads values from some nodes and does some further processing. In general, everything works as expected, but if set the execution period to 1 second, after some iterations, I get BadSecurityChecksFailed and the secure channel closes while the session goes from Activated to Created.
opcua_1.png

I modified my program, so when secure channel closes, it tries to reconnect using the same "UA_Client_connectUsername()" function., which should connect if not connected, or report that it is already connected otherwise.

The problem is that it doesn't reconnect. I get a warning that the client is already connected, though the status is secureChannel:Closed and session:Created.
opcua_2.png

My basic question is, how does open62541 handle sessions and connections? It is not clear in the documentation.
In addition, how can my client reconnect to an already open session creating a new channel? Isn't that handled by "UA_Client_connectUsername()" function?

Any hint to the right direction, will be highly appreciated.

Thank you in advance!
Stam

Daniel Gonçalves

unread,
Jun 30, 2022, 10:49:47 AMJun 30
to open62541
Did you figure it out? I'm having the same issue.

Stamatis Poulios

unread,
Jul 4, 2022, 4:40:54 AMJul 4
to Daniel Gonçalves, open62541
Dear Daniel,

I can't tell you for sure, since it's been a year since this post. By inspecting my code, I see that I have changed the connection logic based on the example https://github.com/open62541/open62541/blob/master/examples/client_connect_loop.c

I am not sure, but perhaps the sleep (on line 52 of the code on the link), does the trick.

Hope that helps,
Stam

--
You received this message because you are subscribed to a topic in the Google Groups "open62541" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/open62541/oDzoCn8wWmQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to open62541+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/open62541/9387e5e3-04c7-4fec-8634-205aa1ac0a68n%40googlegroups.com.

Julius Pfrommer

unread,
Jul 12, 2022, 4:25:27 AMJul 12
to open62541
Hey there,

We just pushed a huge update to the client on master.
Automatic reconnect is also covered in the unit tests.

I suppose you are on v1.3 or master from a few weeks ago.

Can you try with the current master?
Let's then open an issue to fix for master and / or 1.3.

Regards, Julius
Reply all
Reply to author
Forward
0 new messages