0

I'm building a server using the open62541 OPC UA stack version 1.0. This works great so far.

When a client disconnects I need to do some maintenance at server side. Is there a possibility to execute a callback when a client disconnects from the OPC UA server? Alternatively also a "session closed" or "secure channel closed" can help.

Thanks for support.

EDIT: ... so, I checked again the documentation of the Access Control API but it's not clear to me how to apply it for my problem. If i run the server with

int main(void) {
    signal(SIGINT, stopHandler);
    signal(SIGTERM, stopHandler);
    UA_Server *server = UA_Server_new();
    UA_ServerConfig_setDefault(UA_Server_getConfig(server));
    UA_StatusCode retval = UA_Server_run(server, &running);
    UA_Server_delete(server);
    return retval == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE;
}

I only have the server pointer and maybe the config. From here how is the server notified when a client connects/disconnects and how can i catch this event or do i need to periodically check if there are connected clients using a Timed Callback? If yes how? And where comes the Access Control API into game?

Thanks again

SRA
  • 3
  • 3
  • Welcome to StackOverflow. What have you investigated (any hints in the documentation)? – Jeroen Heier Dec 02 '19 at 17:43
  • I investigated the Access Controm API documentation (as Schroeder answered) but I can't find a way/solution to get the Access Control "object" and within that the status info of connected clients... Maybe I have to investigate a little bit more with the using the links that Schroeder posted... – SRA Dec 03 '19 at 21:15
  • And thanks for the welcome. – SRA Dec 03 '19 at 21:15

1 Answers1

0

You can use the Access Control Plugin API, to get when a client connectes and disconnectes. (activateSession/closeSession).

See:

Access Control documentation

The default plugin as starting point

Schroeder
  • 749
  • 4
  • 10
  • Thanks for the fast reply I will try to apply your answers this or next week and give feedback asap. – SRA Dec 03 '19 at 21:16
  • Do I have to change the AccessControl_default.c and complie it into the amalgamated files (*.c/*.h) ? – SRA Dec 05 '19 at 10:03
  • You can replace accessControl in your UA_ServerConfig and init the UA_AccessControl struct with your function pointers and data. – Schroeder Dec 05 '19 at 10:32
  • Seems legit and makes sense to me now. I will give it a try. Thank you very much for your help. – SRA Dec 06 '19 at 16:53