Skip to content

Commit fc1f813

Browse files
author
Ahmad Noman Musleh
committed
Added separate cancellation tokens for TCP read operations
1 parent 6bce3c1 commit fc1f813

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/OpenAPI.Net/OpenAPI.Net.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<PackageTags>cTrader, Open API, Spotware</PackageTags>
1010
<Description>A .NET RX library for Spotware Open API</Description>
1111
<PackageId>Spotware.OpenAPI.Net</PackageId>
12-
<Version>1.3.7-rc0</Version>
12+
<Version>1.3.7-rc1</Version>
1313
<Platforms>AnyCPU</Platforms>
1414
<Company>Spotware</Company>
1515
<Authors>Spotware</Authors>

src/OpenAPI.Net/OpenClient.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,9 @@ private async Task ReadTcp(CancellationToken cancellationToken)
387387
{
388388
var count = lengthArray.Length - readBytes;
389389

390-
readBytes += await _sslStream.ReadAsync(lengthArray, readBytes, count, cancellationToken).ConfigureAwait(false);
390+
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20));
391+
392+
readBytes += await _sslStream.ReadAsync(lengthArray, readBytes, count, cancellationTokenSource.Token).ConfigureAwait(false);
391393
}
392394
while (readBytes < lengthArray.Length);
393395

@@ -405,7 +407,9 @@ private async Task ReadTcp(CancellationToken cancellationToken)
405407
{
406408
var count = data.Length - readBytes;
407409

408-
readBytes += await _sslStream.ReadAsync(data, readBytes, count, cancellationToken).ConfigureAwait(false);
410+
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(20));
411+
412+
readBytes += await _sslStream.ReadAsync(data, readBytes, count, cancellationTokenSource.Token).ConfigureAwait(false);
409413
}
410414
while (readBytes < length);
411415

0 commit comments

Comments
 (0)