Skip to content

Commit 6a231e0

Browse files
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.
1 parent c1a70de commit 6a231e0

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

AMWD.Protocols.Modbus.Proxy/ModbusTcpProxy.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class ModbusTcpProxy : IDisposable
2222

2323
private bool _isDisposed;
2424

25+
private TimeSpan _readWriteTimeout = TimeSpan.FromSeconds(100);
26+
2527
private TcpListener _listener;
2628
private CancellationTokenSource _stopCts;
2729
private Task _clientConnectTask = Task.CompletedTask;
@@ -92,8 +94,19 @@ public ModbusTcpProxy(ModbusClientBase client, IPAddress listenAddress = null, i
9294

9395
/// <summary>
9496
/// Gets or sets the read/write timeout for the incoming connections (not the <see cref="Client"/>!).
97+
/// Default: 100 seconds.
9598
/// </summary>
96-
public TimeSpan ReadWriteTimeout { get; set; }
99+
public TimeSpan ReadWriteTimeout
100+
{
101+
get => _readWriteTimeout;
102+
set
103+
{
104+
if (value != Timeout.InfiniteTimeSpan && value < TimeSpan.Zero)
105+
throw new ArgumentOutOfRangeException(nameof(value));
106+
107+
_readWriteTimeout = value;
108+
}
109+
}
97110

98111
#endregion Properties
99112

AMWD.Protocols.Modbus.Tests/AMWD.Protocols.Modbus.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
<PrivateAssets>all</PrivateAssets>
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
</PackageReference>
23-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
23+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
2424
<PackageReference Include="Moq" Version="4.20.72" />
25-
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
26-
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
25+
<PackageReference Include="MSTest.TestAdapter" Version="3.6.4" />
26+
<PackageReference Include="MSTest.TestFramework" Version="3.6.4" />
2727
</ItemGroup>
2828

2929
<ItemGroup>

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
_no changes_
10+
### Changed
11+
12+
- The `ModbusTcpProxy.ReadWriteTimeout` has a default of 100 seconds (same default as a `HttpClient` has).
1113

1214

1315
## [v0.3.2] (2024-09-04)

0 commit comments

Comments
 (0)