diff --git a/test/AspNetCoreModule.TestSites.Standard/WebSocketConnections.cs b/test/AspNetCoreModule.TestSites.Standard/WebSocketConnections.cs index 7957c59..a39aaed 100644 --- a/test/AspNetCoreModule.TestSites.Standard/WebSocketConnections.cs +++ b/test/AspNetCoreModule.TestSites.Standard/WebSocketConnections.cs @@ -48,13 +48,19 @@ namespace AspnetCoreModule.TestSites.Standard _closeAllStarted = true; var buffer = new byte[1024 * 4]; - // send close message to client - foreach (KeyValuePair entry in _webSockets) + try { - await entry.Value.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, ClosingFromServer, CancellationToken.None); + // send close message to client + foreach (KeyValuePair entry in _webSockets) + { + await entry.Value.CloseOutputAsync(WebSocketCloseStatus.NormalClosure, ClosingFromServer, CancellationToken.None); + } + _webSockets.Clear(); + } + catch (Exception ex) + { + Console.WriteLine("CloseAll() run into exception error!!! " + ex.Message); } - - _webSockets.Clear(); _closeAllStarted = false; } }