This is an automated email from the ASF dual-hosted git repository.

tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-proton-dotnet.git


The following commit(s) were added to refs/heads/main by this push:
     new 178fae3  PROTON-2805 Ensure client configures half the idle timeout set
178fae3 is described below

commit 178fae3b0d7e61093c66674100f0d3e13011a77f
Author: Timothy Bish <[email protected]>
AuthorDate: Thu Mar 14 16:32:52 2024 -0400

    PROTON-2805 Ensure client configures half the idle timeout set
    
    Client connection should configure the engine with half the configured idle 
timeout
    value that is set in the options.
---
 src/Proton.Client/Client/ConnectionOptions.cs      |  5 +--
 .../Client/Implementation/ClientConnection.cs      |  2 +-
 .../Client/Implementation/ClientConnectionTest.cs  | 38 ++++++++++++++++++++++
 .../Implementation/ClientReconnectSessionTest.cs   |  2 +-
 4 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/src/Proton.Client/Client/ConnectionOptions.cs 
b/src/Proton.Client/Client/ConnectionOptions.cs
index 0c037a0..30b18ca 100644
--- a/src/Proton.Client/Client/ConnectionOptions.cs
+++ b/src/Proton.Client/Client/ConnectionOptions.cs
@@ -29,7 +29,7 @@ namespace Apache.Qpid.Proton.Client
       public static readonly long DEFAULT_CLOSE_TIMEOUT = 60000;
       public static readonly long DEFAULT_SEND_TIMEOUT = INFINITE;
       public static readonly long DEFAULT_REQUEST_TIMEOUT = INFINITE;
-      public static readonly long DEFAULT_IDLE_TIMEOUT = 60000;
+      public static readonly uint DEFAULT_IDLE_TIMEOUT = 60000;
       public static readonly long DEFAULT_DRAIN_TIMEOUT = 60000;
       public static readonly ushort DEFAULT_CHANNEL_MAX = 65535;
       public static readonly uint DEFAULT_MAX_FRAME_SIZE = 65536;
@@ -161,8 +161,9 @@ namespace Apache.Qpid.Proton.Client
       /// defaults if child resources are not created with their own options 
type.  Controls
       /// the idle processing timeout that is sent to the remote informing it 
up the clients
       /// expectation for how long it can remain idle before needing to send a 
heart beat.
+      /// The client sends half the configured value to the remote
       /// </summary>
-      public long IdleTimeout { get; set; } = DEFAULT_IDLE_TIMEOUT;
+      public uint IdleTimeout { get; set; } = DEFAULT_IDLE_TIMEOUT;
 
       /// <summary>
       /// Gets or sets the connection level drain timeout value which will be 
used as the
diff --git a/src/Proton.Client/Client/Implementation/ClientConnection.cs 
b/src/Proton.Client/Client/Implementation/ClientConnection.cs
index b3c4e83..751286e 100644
--- a/src/Proton.Client/Client/Implementation/ClientConnection.cs
+++ b/src/Proton.Client/Client/Implementation/ClientConnection.cs
@@ -991,7 +991,7 @@ namespace Apache.Qpid.Proton.Client.Implementation
          protonConnection.LinkedResource = this;
          protonConnection.ChannelMax = options.ChannelMax;
          protonConnection.MaxFrameSize = options.MaxFrameSize;
-         protonConnection.IdleTimeout = (uint)options.IdleTimeout;
+         protonConnection.IdleTimeout = options.IdleTimeout / 2;
          protonConnection.OfferedCapabilities = 
ClientConversionSupport.ToSymbolArray(options.OfferedCapabilities);
          protonConnection.DesiredCapabilities = 
ClientConversionSupport.ToSymbolArray(options.DesiredCapabilities);
          protonConnection.Properties = 
ClientConversionSupport.ToSymbolKeyedMap(options.Properties);
diff --git 
a/test/Proton.Client.Tests/Client/Implementation/ClientConnectionTest.cs 
b/test/Proton.Client.Tests/Client/Implementation/ClientConnectionTest.cs
index 3b4198a..e2040bf 100644
--- a/test/Proton.Client.Tests/Client/Implementation/ClientConnectionTest.cs
+++ b/test/Proton.Client.Tests/Client/Implementation/ClientConnectionTest.cs
@@ -2017,6 +2017,44 @@ namespace Apache.Qpid.Proton.Client.Implementation
          }
       }
 
+      [Test]
+      public void TestCreateConnectionSendsHalfIdleTimeout()
+      {
+         DoTestCreateConnectionSendsExpectedIdleTimeout(10_000U, 5_000U);
+      }
+
+      [Test]
+      public void TestCreateConnectionSendsConfiguredZeroTimeout()
+      {
+         DoTestCreateConnectionSendsExpectedIdleTimeout(0U, 0U);
+      }
+
+      private void DoTestCreateConnectionSendsExpectedIdleTimeout(uint 
configured, uint expected)
+      {
+         using (ProtonTestServer peer = new ProtonTestServer(loggerFactory))
+         {
+            peer.ExpectSASLAnonymousConnect();
+            peer.ExpectOpen().WithIdleTimeOut(expected).Respond();
+            peer.ExpectClose().Respond();
+            peer.Start();
+
+            string remoteAddress = peer.ServerAddress;
+            int remotePort = peer.ServerPort;
+
+            logger.LogInformation("Test started, peer listening on: {0}:{1}", 
remoteAddress, remotePort);
+
+            IClient container = IClient.Create();
+            ConnectionOptions options = ConnectionOptions("guest", "guest");
+            options.IdleTimeout = configured;
+            IConnection connection = container.Connect(remoteAddress, 
remotePort, options);
+
+            _ = connection.OpenTask.Wait(TimeSpan.FromSeconds(10));
+            _ = connection.CloseAsync().Wait(TimeSpan.FromSeconds(10));
+
+            peer.WaitForScriptToComplete();
+         }
+      }
+
       [Ignore("Client local bind not yet implemented")]
       [Test]
       public void TestLocalPortOption()
diff --git 
a/test/Proton.Client.Tests/Client/Implementation/ClientReconnectSessionTest.cs 
b/test/Proton.Client.Tests/Client/Implementation/ClientReconnectSessionTest.cs
index 027e5aa..001812d 100644
--- 
a/test/Proton.Client.Tests/Client/Implementation/ClientReconnectSessionTest.cs
+++ 
b/test/Proton.Client.Tests/Client/Implementation/ClientReconnectSessionTest.cs
@@ -165,7 +165,7 @@ namespace Apache.Qpid.Proton.Client.Implementation
 
             ConnectionOptions options = new ConnectionOptions();
             options.ReconnectOptions.ReconnectEnabled = true;
-            options.IdleTimeout = TimeSpan.FromSeconds(5).Milliseconds;
+            options.IdleTimeout = (uint)TimeSpan.FromSeconds(5).Milliseconds;
             options.ReconnectOptions.AddReconnectLocation(intermediateAddress, 
intermediatePort);
             options.ReconnectOptions.AddReconnectLocation(finalAddress, 
finalPort);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to