@@ -104,7 +104,6 @@ class OpcUaClientConnection {
104104 endpointFilter ,
105105 ignore -> {},
106106 new OpcUaClientConfigurator (adapterId , parsedConfig ));
107- client .addSessionActivityListener (activityListener );
108107 client .addFaultListener (faultListener );
109108 client .connect ();
110109 } catch (final UaException e ) {
@@ -122,13 +121,13 @@ class OpcUaClientConnection {
122121
123122 if (subscriptionOptional .isEmpty ()) {
124123 log .error ("Failed to create or transfer OPC UA subscription. Closing client connection." );
125- quietlyCloseClient (client , false ,null , null );
126124 protocolAdapterState .setConnectionStatus (ProtocolAdapterState .ConnectionStatus .ERROR );
127125 eventService
128126 .createAdapterEvent (adapterId , PROTOCOL_ID_OPCUA )
129127 .withMessage ("Failed to create or transfer OPC UA subscription. Closing client connection." )
130128 .withSeverity (Event .SEVERITY .ERROR )
131129 .fire ();
130+ quietlyCloseClient (client , false , faultListener , activityListener );
132131 return false ;
133132 }
134133
@@ -137,6 +136,7 @@ class OpcUaClientConnection {
137136
138137 context .set (new ConnectionContext (subscription .getClient (), faultListener , activityListener ));
139138 protocolAdapterState .setConnectionStatus (ProtocolAdapterState .ConnectionStatus .CONNECTED );
139+ client .addSessionActivityListener (activityListener );
140140 log .info ("Client created and connected successfully" );
141141 return true ;
142142 }
0 commit comments