ReadWriteTimeout for ModbusTcpProxy changed

As suggestion of #5 on GitHub, the default value of the timeout changed.
But to the same timeout as on HttpClient and not infinite.
This commit is contained in:
2024-12-13 17:58:34 +01:00
parent c1a70de6bb
commit 6a231e02cb
3 changed files with 20 additions and 5 deletions

View File

@@ -22,6 +22,8 @@ namespace AMWD.Protocols.Modbus.Proxy
private bool _isDisposed; private bool _isDisposed;
private TimeSpan _readWriteTimeout = TimeSpan.FromSeconds(100);
private TcpListener _listener; private TcpListener _listener;
private CancellationTokenSource _stopCts; private CancellationTokenSource _stopCts;
private Task _clientConnectTask = Task.CompletedTask; private Task _clientConnectTask = Task.CompletedTask;
@@ -92,8 +94,19 @@ namespace AMWD.Protocols.Modbus.Proxy
/// <summary> /// <summary>
/// Gets or sets the read/write timeout for the incoming connections (not the <see cref="Client"/>!). /// Gets or sets the read/write timeout for the incoming connections (not the <see cref="Client"/>!).
/// Default: 100 seconds.
/// </summary> /// </summary>
public TimeSpan ReadWriteTimeout { get; set; } public TimeSpan ReadWriteTimeout
{
get => _readWriteTimeout;
set
{
if (value != Timeout.InfiniteTimeSpan && value < TimeSpan.Zero)
throw new ArgumentOutOfRangeException(nameof(value));
_readWriteTimeout = value;
}
}
#endregion Properties #endregion Properties

View File

@@ -20,10 +20,10 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="Moq" Version="4.20.72" /> <PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" /> <PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" /> <PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
_no changes_ ### Changed
- The `ModbusTcpProxy.ReadWriteTimeout` has a default of 100 seconds (same default as a `HttpClient` has).
## [v0.3.2] (2024-09-04) ## [v0.3.2] (2024-09-04)