From 02a9bde10ddd71e5b76338b1e7ff0a0e3607d658 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 24 May 2018 17:29:15 +1200 Subject: [PATCH] Fix flaky ClientPingsMultipleTimes test (#2368) --- src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs | 3 +-- .../HubConnectionTests.Protocol.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs b/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs index fb371fcb25..7a5c02da93 100644 --- a/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs +++ b/src/Microsoft.AspNetCore.SignalR.Client.Core/HubConnection.cs @@ -34,7 +34,6 @@ namespace Microsoft.AspNetCore.SignalR.Client public static readonly TimeSpan DefaultServerTimeout = TimeSpan.FromSeconds(30); // Server ping rate is 15 sec, this is 2 times that. public static readonly TimeSpan DefaultHandshakeTimeout = TimeSpan.FromSeconds(15); public static readonly TimeSpan DefaultPingInterval = TimeSpan.FromSeconds(15); - public static readonly TimeSpan DefaultTickRate = TimeSpan.FromSeconds(1); // This lock protects the connection state. private readonly SemaphoreSlim _connectionLock = new SemaphoreSlim(1, 1); @@ -56,7 +55,7 @@ namespace Microsoft.AspNetCore.SignalR.Client public event Func Closed; // internal for testing purposes - internal TimeSpan TickRate { get; set; } = DefaultTickRate; + internal TimeSpan TickRate { get; set; } = TimeSpan.FromSeconds(1); /// /// Gets or sets the server timeout interval for the connection. diff --git a/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionTests.Protocol.cs b/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionTests.Protocol.cs index 3a4d78ac45..c1603c55ff 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionTests.Protocol.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.Tests/HubConnectionTests.Protocol.cs @@ -580,10 +580,10 @@ namespace Microsoft.AspNetCore.SignalR.Client.Tests { await hubConnection.StartAsync().OrTimeout(); - var firstPing = await connection.ReadSentTextMessageAsync().OrTimeout(TimeSpan.FromMilliseconds(200)); + var firstPing = await connection.ReadSentTextMessageAsync().OrTimeout(); Assert.Equal("{\"type\":6}", firstPing); - var secondPing = await connection.ReadSentTextMessageAsync().OrTimeout(TimeSpan.FromMilliseconds(200)); + var secondPing = await connection.ReadSentTextMessageAsync().OrTimeout(); Assert.Equal("{\"type\":6}", secondPing); } finally