diff --git a/clients/ts/signalr/src/LongPollingTransport.ts b/clients/ts/signalr/src/LongPollingTransport.ts index ff75fa91fa..0cf69c51de 100644 --- a/clients/ts/signalr/src/LongPollingTransport.ts +++ b/clients/ts/signalr/src/LongPollingTransport.ts @@ -59,7 +59,7 @@ export class LongPollingTransport implements ITransport { const pollOptions: HttpRequest = { abortSignal: this.pollAbort.signal, headers: {}, - timeout: 90000, + timeout: 100000, }; if (transferFormat === TransferFormat.Binary) { diff --git a/src/Microsoft.AspNetCore.Http.Connections/Internal/HttpConnectionContext.cs b/src/Microsoft.AspNetCore.Http.Connections/Internal/HttpConnectionContext.cs index a12e8aba61..045e821ee1 100644 --- a/src/Microsoft.AspNetCore.Http.Connections/Internal/HttpConnectionContext.cs +++ b/src/Microsoft.AspNetCore.Http.Connections/Internal/HttpConnectionContext.cs @@ -182,6 +182,8 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal { Task disposeTask; + Cancellation?.Dispose(); + await StateLock.WaitAsync(); try { diff --git a/src/Microsoft.AspNetCore.Http.Connections/Internal/HttpConnectionDispatcher.cs b/src/Microsoft.AspNetCore.Http.Connections/Internal/HttpConnectionDispatcher.cs index f8c33e051f..e13b532e16 100644 --- a/src/Microsoft.AspNetCore.Http.Connections/Internal/HttpConnectionDispatcher.cs +++ b/src/Microsoft.AspNetCore.Http.Connections/Internal/HttpConnectionDispatcher.cs @@ -313,10 +313,6 @@ namespace Microsoft.AspNetCore.Http.Connections.Internal connection.LastSeenUtc = DateTime.UtcNow; connection.Status = HttpConnectionStatus.Inactive; - - connection.Cancellation?.Cancel(); - - connection.Cancellation = null; } } finally diff --git a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs index c300c4bb23..6ba1bbeb5e 100644 --- a/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs +++ b/test/Microsoft.AspNetCore.SignalR.Client.FunctionalTests/HubConnectionTests.cs @@ -398,8 +398,15 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests [MemberData(nameof(HubProtocolsAndTransportsAndHubPaths))] public async Task StreamDoesNotStartIfTokenAlreadyCanceled(string protocolName, HttpTransportType transportType, string path) { + bool ExpectedErrors(WriteContext writeContext) + { + return (writeContext.LoggerName == nameof(Http.Connections.Client.Internal.ServerSentEventsTransport) || + writeContext.LoggerName == nameof(Http.Connections.Client.Internal.LongPollingTransport)) && + writeContext.EventId.Name == "ErrorSending"; + } + var protocol = HubProtocols[protocolName]; - using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(StreamDoesNotStartIfTokenAlreadyCanceled)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}")) + using (StartVerifiableLog(out var loggerFactory, LogLevel.Trace, $"{nameof(StreamDoesNotStartIfTokenAlreadyCanceled)}_{protocol.Name}_{transportType}_{path.TrimStart('/')}", expectedErrorsFilter: ExpectedErrors)) { var connection = CreateHubConnection(path, transportType, protocol, loggerFactory); try diff --git a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Docker.cs b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Docker.cs index 94b19673e7..29285aa3e6 100644 --- a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Docker.cs +++ b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/Docker.cs @@ -50,6 +50,13 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests private static string GetDockerLocation() { + // OSX + Docker + Redis don't play well together for some reason. We already have these tests covered on Linux and Windows + // So we are happy ignoring them on OSX + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + { + return null; + } + foreach (var dir in Environment.GetEnvironmentVariable("PATH").Split(Path.PathSeparator)) { var candidate = Path.Combine(dir, "docker" + _exeSuffix); diff --git a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisServerFixture.cs b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisServerFixture.cs index e3f3b7f9d7..e2fab22665 100644 --- a/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisServerFixture.cs +++ b/test/Microsoft.AspNetCore.SignalR.Redis.Tests/RedisServerFixture.cs @@ -28,7 +28,7 @@ namespace Microsoft.AspNetCore.SignalR.Redis.Tests } var testLog = AssemblyTestLog.ForAssembly(typeof(RedisServerFixture).Assembly); - _logToken = testLog.StartTestLog(null, $"{nameof(RedisServerFixture)}_{typeof(TStartup).Name}", out _loggerFactory, "RedisServerFixture"); + _logToken = testLog.StartTestLog(null, $"{nameof(RedisServerFixture)}_{typeof(TStartup).Name}", out _loggerFactory, LogLevel.Trace, "RedisServerFixture"); _logger = _loggerFactory.CreateLogger>(); Docker.Default.Start(_logger); diff --git a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/ServerLogScope.cs b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/ServerLogScope.cs index 1b4ff4e05c..37d9e6fb0e 100644 --- a/test/Microsoft.AspNetCore.SignalR.Tests.Utils/ServerLogScope.cs +++ b/test/Microsoft.AspNetCore.SignalR.Tests.Utils/ServerLogScope.cs @@ -15,6 +15,7 @@ namespace Microsoft.AspNetCore.SignalR.Tests private readonly ConcurrentDictionary _serverLoggers; private readonly ILogger _scopeLogger; private readonly object _lock; + private bool _disposed; public ServerLogScope(ServerFixture serverFixture, ILoggerFactory loggerFactory, IDisposable wrappedDisposable) { @@ -45,11 +46,15 @@ namespace Microsoft.AspNetCore.SignalR.Tests ILogger logger; - // There maybe thready safety issues in logging when creating multiple loggers at the same time - // https://github.com/aspnet/Logging/issues/810 lock (_lock) { + if (_disposed) + { + return; + } + // Create (or get) a logger with the same name as the server logger + // Call in the lock to avoid ODE where LoggerFactory could be disposed by the wrapped disposable logger = _serverLoggers.GetOrAdd(write.LoggerName, loggerName => _loggerFactory.CreateLogger("SERVER " + loggerName)); } @@ -62,7 +67,11 @@ namespace Microsoft.AspNetCore.SignalR.Tests _scopeLogger.LogInformation("Server log scope stopped."); - _wrappedDisposable?.Dispose(); + lock (_lock) + { + _wrappedDisposable?.Dispose(); + _disposed = true; + } } } } \ No newline at end of file