diff --git a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs index 2edd8f6e47..b4315644b2 100644 --- a/src/Microsoft.Net.WebSockets/CommonWebSocket.cs +++ b/src/Microsoft.Net.WebSockets/CommonWebSocket.cs @@ -156,10 +156,9 @@ namespace Microsoft.Net.WebSockets private async void SendKeepAliveAsync() { // Check concurrent writes, pings & pongs, or closes - bool lockAquired = await _writeLock.WaitAsync(TimeSpan.FromMinutes(1)); // TODO: Wait up to KeepAliveInterval? - if (!lockAquired) + if (!_writeLock.Wait(0)) { - // Pings aren't that important, discard them if we can't take the lock. + // Sending real data is better than a ping, discard it. return; } try