Skip to content

Commit 90c6430

Browse files
author
Ahmad Noman Musleh
committed
Fixed TCP mode disconnection issue
1 parent 371638b commit 90c6430

5 files changed

Lines changed: 7 additions & 15 deletions

File tree

src/ASP.NET.Sample/README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,4 @@ The app will load your Open API application credentials and it will use it.
1616

1717
You have to also add your web app host URL in your API application redirect URIs, otherwise the account authorization will not work and you will get an error.
1818

19-
The application default URL is set to https://localhost:5001/ and http://localhost:5000/, add both to your API application redirect URIs.
20-
2119
You can find the application URL on project/properties/launchSettings.json file, you can change it from there if you want to.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ApiCredentials": {
3-
"ClientId": "2175_xzl5IOUElxoQJSXIOrJz7Da65B0bFv8K9xLjYhL7eO85sKT885",
4-
"Secret": "pA5Yova9jEpzgVMYCjTrS54LCX31MD0chqO94wDScE1qHgko3C"
3+
"ClientId": "699_9UIX3RJWkl3BwGfKi30xzfiyCaMkEA1FLKD020gy57i4e3XplL",
4+
"Secret": "dfJVd3Ud1HkLcQJaLPx5fmEqR8iUkmLYeCBikQUa6J3bJH2Jce"
55
}
66
}

src/Blazor.WebSocket.Sample/Pages/Index.razor

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,6 @@
427427
await Task.Delay(1000);
428428

429429
await ApiCredentialsModal.Open();
430-
431-
ApiService.Error += exception => Console.Error.WriteLine($"API Service Exception: {exception}");
432430
}
433431

434432
private async Task Connect()

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.4</Version>
12+
<Version>1.3.5</Version>
1313
<Platforms>AnyCPU</Platforms>
1414
<Company>Spotware</Company>
1515
<Authors>Spotware</Authors>

src/OpenAPI.Net/OpenClient.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,13 @@ public async Task SendMessageInstant(ProtoMessage message)
258258
{
259259
var messageByte = message.ToByteArray();
260260

261-
var length = BitConverter.GetBytes(messageByte.Length);
262-
263-
Array.Reverse(length);
264-
265261
if (UseWebSocket)
266262
{
267263
_websocketClient.Send(messageByte);
268264
}
269265
else
270266
{
271-
await WriteTcp(messageByte, length);
267+
await WriteTcp(messageByte);
272268
}
273269

274270
LastSentMessageTime = DateTimeOffset.Now;
@@ -406,15 +402,15 @@ private async Task<ProtoMessage> ReadTcp()
406402
/// <param name="messageByte"></param>
407403
/// <param name="length"></param>
408404
/// <returns>Task</returns>
409-
private async Task WriteTcp(byte[] messageByte, byte[] length)
405+
private async Task WriteTcp(byte[] messageByte)
410406
{
411407
ThrowObjectDisposedExceptionIfDisposed();
412408

413409
try
414410
{
415-
await _sslStream.WriteAsync(length, 0, length.Length).ConfigureAwait(false);
411+
var data = BitConverter.GetBytes(messageByte.Length).Reverse().Concat(messageByte).ToArray();
416412

417-
await _sslStream.WriteAsync(messageByte, 0, messageByte.Length).ConfigureAwait(false);
413+
await _sslStream.WriteAsync(data, 0, data.Length).ConfigureAwait(false);
418414
}
419415
catch (Exception ex)
420416
{

0 commit comments

Comments
 (0)