From c36ddcc065034ed52e308b3ae54373b928d1a120 Mon Sep 17 00:00:00 2001 From: Yaakov Date: Fri, 24 Mar 2023 15:57:46 +1100 Subject: [PATCH] handle reconnects more gracefully --- DepotDownloader/Steam3Session.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/DepotDownloader/Steam3Session.cs b/DepotDownloader/Steam3Session.cs index db42df8d..976bd833 100644 --- a/DepotDownloader/Steam3Session.cs +++ b/DepotDownloader/Steam3Session.cs @@ -482,6 +482,12 @@ namespace DepotDownloader Console.WriteLine(" Done!"); bConnecting = false; bConnected = true; + + // Update our tracking so that we don't time out, even if we need to reconnect multiple times, + // e.g. if the authentication phase takes a while and therefore multiple connections. + connectTime = DateTime.Now; + connectionBackoff = 0; + if (!authenticatedUser) { Console.Write("Logging anonymously into Steam3..."); @@ -515,10 +521,15 @@ namespace DepotDownloader AccountSettingsStore.Instance.LoginTokens[result.AccountName] = result.RefreshToken; AccountSettingsStore.Save(); } + catch (TaskCanceledException) + { + return; + } catch (Exception ex) { Console.Error.WriteLine("Failed to authenticate with Steam: " + ex.Message); Abort(false); + return; } } else if (ContentDownloader.Config.UseQrCode) @@ -554,10 +565,15 @@ namespace DepotDownloader AccountSettingsStore.Instance.LoginTokens[result.AccountName] = result.RefreshToken; AccountSettingsStore.Save(); } + catch (TaskCanceledException) + { + return; + } catch (Exception ex) { Console.Error.WriteLine("Failed to authenticate with Steam: " + ex.Message); Abort(false); + return; } } @@ -569,6 +585,8 @@ namespace DepotDownloader { bDidDisconnect = true; + DebugLog.WriteLine(nameof(Steam3Session), $"Disconnected: bIsConnectionRecovery = {bIsConnectionRecovery}, UserInitiated = {disconnected.UserInitiated}, bExpectingDisconnectRemote = {bExpectingDisconnectRemote}"); + // When recovering the connection, we want to reconnect even if the remote disconnects us if (!bIsConnectionRecovery && (disconnected.UserInitiated || bExpectingDisconnectRemote)) {