Skip to content

Commit

Permalink
Merge pull request #2161 from OPCFoundation/master371
Browse files Browse the repository at this point in the history
Merge updated master371 branch in release/1.4.371
  • Loading branch information
mregen committed May 24, 2023
2 parents 0f5fc44 + a81a696 commit c9fe45a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Applications/ConsoleReferenceClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static async Task Main(string[] args)
};

// load the application configuration.
var config = await application.LoadApplicationConfiguration(silent: false);
var config = await application.LoadApplicationConfiguration(silent: false).ConfigureAwait(false);

// override logfile
if (logFile != null)
Expand Down Expand Up @@ -189,7 +189,7 @@ public static async Task Main(string[] args)
uaClient.UserIdentity = new UserIdentity(username, userpassword ?? string.Empty);
}

bool connected = await uaClient.ConnectAsync(serverUrl.ToString(), false);
bool connected = await uaClient.ConnectAsync(serverUrl.ToString(), false).ConfigureAwait(false);
if (connected)
{
output.WriteLine("Connected! Ctrl-C to quit.");
Expand Down Expand Up @@ -229,7 +229,7 @@ public static async Task Main(string[] args)

if (jsonvalues && variableIds != null)
{
await samples.ReadAllValuesAsync(uaClient, variableIds);
await samples.ReadAllValuesAsync(uaClient, variableIds).ConfigureAwait(false);
}

if (subscribe)
Expand Down Expand Up @@ -262,7 +262,7 @@ public static async Task Main(string[] args)
publishingInterval: 5000,
queueSize: 10,
lifetimeCount: 12,
keepAliveCount: 2);
keepAliveCount: 2).ConfigureAwait(false);

// Wait for DataChange notifications from MonitoredItems
quit = quitEvent.WaitOne(timeout > 0 ? waitTime : Timeout.Infinite);
Expand Down
22 changes: 19 additions & 3 deletions Applications/ConsoleReferenceClient/UAClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,27 @@ private void Client_ReconnectComplete(object sender, EventArgs e)
// if session recovered, Session property is null
if (m_reconnectHandler.Session != null)
{
m_session = m_reconnectHandler.Session as Session;
// ensure only a new instance is disposed
// after reactivate, the same session instance may be returned
if (!Object.ReferenceEquals(m_session, m_reconnectHandler.Session))
{
m_output.WriteLine("--- RECONNECTED TO NEW SESSION --- {0}", m_reconnectHandler.Session.SessionId);
var session = m_session;
session.KeepAlive -= Session_KeepAlive;
m_session = m_reconnectHandler.Session as Session;
m_session.KeepAlive += Session_KeepAlive;
Utils.SilentDispose(session);
}
else
{
m_output.WriteLine("--- REACTIVATED SESSION --- {0}", m_reconnectHandler.Session.SessionId);
}
}
else
{
m_output.WriteLine("--- RECONNECT KeepAlive recovered ---");
}
}

m_output.WriteLine("--- RECONNECTED ---");
}
#endregion

Expand Down
7 changes: 7 additions & 0 deletions Libraries/Opc.Ua.Client/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5766,10 +5766,17 @@ private bool BelowPublishRequestLimit(int requestCount)
/// <summary>
/// Returns the minimum number of active publish request that should be used.
/// </summary>
/// <remarks>
/// Returns 0 if there are no subscriptions.
/// </remarks>
private int GetMinPublishRequestCount()
{
lock (SyncRoot)
{
if (m_subscriptions.Count == 0)
{
return 0;
}
return Math.Max(m_subscriptions.Count, m_minPublishRequestCount);
}
}
Expand Down

0 comments on commit c9fe45a

Please sign in to comment.