diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
index d347bd6a6..774ba23ad 100644
--- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs
+++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs
@@ -63,7 +63,7 @@ namespace Discord.WebSocket
internal WebSocketProvider WebSocketProvider { get; private set; }
internal bool AlwaysDownloadUsers { get; private set; }
internal int? HandlerTimeout { get; private set; }
-
+
internal new DiscordSocketApiClient ApiClient => base.ApiClient as DiscordSocketApiClient;
///
public override IReadOnlyCollection Guilds => State.Guilds;
@@ -197,10 +197,10 @@ namespace Discord.WebSocket
}
///
- public override async Task StartAsync()
+ public override async Task StartAsync()
=> await _connection.StartAsync().ConfigureAwait(false);
///
- public override async Task StopAsync()
+ public override async Task StopAsync()
=> await _connection.StopAsync().ConfigureAwait(false);
private async Task OnConnectingAsync()
@@ -251,7 +251,9 @@ namespace Discord.WebSocket
await heartbeatTask.ConfigureAwait(false);
_heartbeatTask = null;
+ // Check if hearbeatTimes is not empty before dequeuing. TryDequeue can cause blocking.
if (!_heartbeatTimes.IsEmpty) while (_heartbeatTimes.TryDequeue(out long time)) { }
+ _lastMessageTime = 0;
await _gatewayLogger.DebugAsync("Waiting for guild downloader").ConfigureAwait(false);
if (_guildDownloadTask != null)