diff --git a/cs/build/build.props b/cs/build/build.props
index 8585e1d6..8d18c516 100644
--- a/cs/build/build.props
+++ b/cs/build/build.props
@@ -41,7 +41,7 @@
5.3.9
4.7.2
15.5.31
- 3.12.8
+ 3.12.11
2.4.0
2.4.0
diff --git a/cs/src/Connections/ITunnelClient.cs b/cs/src/Connections/ITunnelClient.cs
index 1ad150cd..e2de7383 100644
--- a/cs/src/Connections/ITunnelClient.cs
+++ b/cs/src/Connections/ITunnelClient.cs
@@ -202,6 +202,16 @@ Task ConnectAsync(
/// configured . This callback is only invoked
/// if the keep-alive interval is greater than 0.
///
- public event EventHandler? KeepAliveFailed;
+ public event EventHandler? KeepAliveFailed;
+
+ ///
+ /// Event raised when a keep-alive message response is received.
+ ///
+ ///
+ /// The event args provide the count of keep-alive messages that got a response within the
+ /// configured . This callback is only invoked
+ /// if the keep-alive interval is greater than 0.
+ ///
+ public event EventHandler? KeepAliveSucceeded;
}
diff --git a/cs/src/Connections/ITunnelHost.cs b/cs/src/Connections/ITunnelHost.cs
index 7497682a..5287607c 100644
--- a/cs/src/Connections/ITunnelHost.cs
+++ b/cs/src/Connections/ITunnelHost.cs
@@ -127,7 +127,7 @@ Task ConnectAsync(
/// ForwardedPortConnecting event will be raised.
///
event EventHandler? ForwardedPortConnecting;
-
+
///
/// Event raised when a keep-alive message response is not received.
///
@@ -136,5 +136,15 @@ Task ConnectAsync(
/// configured . This callback is only invoked
/// if the keep-alive interval is greater than 0.
///
- public event EventHandler? KeepAliveFailed;
+ public event EventHandler? KeepAliveFailed;
+
+ ///
+ /// Event raised when a keep-alive message response is received.
+ ///
+ ///
+ /// The event args provide the count of keep-alive messages that got a response within the
+ /// configured . This callback is only invoked
+ /// if the keep-alive interval is greater than 0.
+ ///
+ public event EventHandler? KeepAliveSucceeded;
}
diff --git a/cs/src/Connections/SshKeepAliveFailureEventArgs.cs b/cs/src/Connections/SshKeepAliveEventArgs.cs
similarity index 52%
rename from cs/src/Connections/SshKeepAliveFailureEventArgs.cs
rename to cs/src/Connections/SshKeepAliveEventArgs.cs
index 6bd8db07..436d3cb9 100644
--- a/cs/src/Connections/SshKeepAliveFailureEventArgs.cs
+++ b/cs/src/Connections/SshKeepAliveEventArgs.cs
@@ -1,27 +1,27 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license.
-//
-
-using System;
-
-namespace Microsoft.DevTunnels.Connections;
-
-///
-/// Event raised when a keep-alive message respose is not received.
-///
-public class SshKeepAliveFailureEventArgs : EventArgs
-{
- ///
- /// Create a new instance of .
- ///
- public SshKeepAliveFailureEventArgs(int count)
- {
- Count = count;
- }
-
- ///
- /// The number of keep-alive messages that have been sent without a response.
- ///
- public int Count { get; }
-}
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license.
+//
+
+using System;
+
+namespace Microsoft.DevTunnels.Connections;
+
+///
+/// Event raised when a keep-alive message respose is or is not received.
+///
+public class SshKeepAliveEventArgs : EventArgs
+{
+ ///
+ /// Create a new instance of .
+ ///
+ public SshKeepAliveEventArgs(int count)
+ {
+ Count = count;
+ }
+
+ ///
+ /// The number of keep-alive messages that have been sent with the same state.
+ ///
+ public int Count { get; }
+}
diff --git a/cs/src/Connections/TunnelClient.cs b/cs/src/Connections/TunnelClient.cs
index 1b2b5d9a..e8048e5e 100644
--- a/cs/src/Connections/TunnelClient.cs
+++ b/cs/src/Connections/TunnelClient.cs
@@ -206,10 +206,14 @@ protected async Task StartSshSessionAsync(Stream stream, TunnelConnectionOptions
session = new SshClientSession(clientConfig, Trace.WithName("SSH"));
SshSession = session;
- session.KeepAliveRequestFailed += (_, e) =>
+ session.KeepAliveFailed += (_, e) =>
{
OnKeepAliveFailed(e.Count);
};
+ session.KeepAliveSucceeded += (_, e) =>
+ {
+ OnKeepAliveSucceeded(e.Count);
+ };
SshPortForwardingService = session.ActivateService();
ConfigurePortForwardingService();
SubscribeSessionEvents(session);
diff --git a/cs/src/Connections/TunnelConnection.cs b/cs/src/Connections/TunnelConnection.cs
index d384f940..26204e77 100644
--- a/cs/src/Connections/TunnelConnection.cs
+++ b/cs/src/Connections/TunnelConnection.cs
@@ -265,7 +265,17 @@ protected virtual void ValidateAccessToken()
/// configured . This callback is only invoked
/// if the keep-alive interval is greater than 0.
///
- public event EventHandler? KeepAliveFailed;
+ public event EventHandler? KeepAliveFailed;
+
+ ///
+ /// Event raised when a keep-alive message response is received.
+ ///
+ ///
+ /// The event args provide the count of keep-alive messages that got a response within the
+ /// configured . This callback is only invoked
+ /// if the keep-alive interval is greater than 0.
+ ///
+ public event EventHandler? KeepAliveSucceeded;
///
/// Fetch the tunnel from the service if and are not null.
@@ -360,7 +370,15 @@ protected virtual async Task OnRefreshingTunnelAccessTokenAsync(Cancellati
///
protected virtual void OnKeepAliveFailed(int count)
{
- KeepAliveFailed?.Invoke(this, new SshKeepAliveFailureEventArgs(count));
+ KeepAliveFailed?.Invoke(this, new SshKeepAliveEventArgs(count));
+ }
+
+ ///
+ /// Event raised when a keep-alive message response is not received.
+ ///
+ protected virtual void OnKeepAliveSucceeded(int count)
+ {
+ KeepAliveSucceeded?.Invoke(this, new SshKeepAliveEventArgs(count));
}
///
diff --git a/cs/src/Connections/TunnelRelayTunnelHost.cs b/cs/src/Connections/TunnelRelayTunnelHost.cs
index 626b6e13..75d008a7 100644
--- a/cs/src/Connections/TunnelRelayTunnelHost.cs
+++ b/cs/src/Connections/TunnelRelayTunnelHost.cs
@@ -207,10 +207,14 @@ protected override async Task ConfigureSessionAsync(Stream stream, bool isReconn
hostPfs.MessageFactory = this;
}
- session.KeepAliveRequestFailed += (_, e) =>
+ session.KeepAliveFailed += (_, e) =>
{
OnKeepAliveFailed(e.Count);
};
+ session.KeepAliveSucceeded += (_, e) =>
+ {
+ OnKeepAliveSucceeded(e.Count);
+ };
SshSession = session;
SubscribeSessionEvents(session);