Skip to content

Commit

Permalink
[Server] Fix Shutdown Delay when registration is enabled no LDS is pr…
Browse files Browse the repository at this point in the history
…esent. (#2589)

* only unregister from Discovery server when registration was successful before
  • Loading branch information
romanett committed May 3, 2024
1 parent 7a04a4b commit 33df292
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Libraries/Opc.Ua.Server/Server/StandardServer.cs
Expand Up @@ -2327,7 +2327,8 @@ public bool RegisterWithDiscoveryServer()
{
client.RegisterServer(requestHeader, m_registrationInfo);
}


m_registeredWithDiscoveryServer = m_registrationInfo.IsOnline;
return true;
}
catch (Exception e)
Expand Down Expand Up @@ -2364,7 +2365,7 @@ public bool RegisterWithDiscoveryServer()
configuration.CertificateValidator.CertificateValidation -= registrationCertificateValidator;
}
}

m_registeredWithDiscoveryServer = false;
return false;
}

Expand Down Expand Up @@ -3012,6 +3013,7 @@ protected override void StartApplication(ApplicationConfiguration configuration)

m_registrationEndpoints.Add(endpoint);

m_registeredWithDiscoveryServer = false;
m_minRegistrationInterval = 1000;
m_lastRegistrationInterval = m_minRegistrationInterval;

Expand Down Expand Up @@ -3080,9 +3082,10 @@ protected override void OnServerStopping()
// attempt graceful shutdown the server.
try
{
if (m_maxRegistrationInterval > 0)

if (m_maxRegistrationInterval > 0 && m_registeredWithDiscoveryServer)
{
// unregister from Discovery Server
// unregister from Discovery Server if registered before
m_registrationInfo.IsOnline = false;
RegisterWithDiscoveryServer();
}
Expand Down Expand Up @@ -3377,6 +3380,7 @@ private void SessionChannelKeepAliveEvent(Session session, SessionEventReason re
private int m_minRegistrationInterval;
private int m_maxRegistrationInterval;
private int m_lastRegistrationInterval;
private bool m_registeredWithDiscoveryServer;
private int m_minNonceLength;
private bool m_useRegisterServer2;
private List<INodeManagerFactory> m_nodeManagerFactories;
Expand Down

0 comments on commit 33df292

Please sign in to comment.