SteamRE / SteamKit

SteamKit2 is a .NET library designed to interoperate with Valve's Steam network. It aims to provide a simple, yet extensible, interface to perform various actions on the network.
GNU Lesser General Public License v2.1
2.62k stars 497 forks source link

[Bug]: getCDNAuthToken no Response #1443

Closed huddhudd closed 1 month ago

huddhudd commented 1 month ago

What did you expect to happen?

getCDNAuthToken Response

Instead of that, what actually happened?

no Response

Which operating system are you running on?

Windows

Which .NET Runtime are you running on?

.NET Framework

Version

.net8

Relevant log output

econnecting in 1 seconds...
Disconnected from Steam
Reconnecting in 1 seconds...
Connected to Steam! Logging in 'vfhhd57968'...
Successfully logged on!
Requesting CDN Auth Token for Depot: 1203221, Server: dl.steam.clngaa.com, AppID: 0

.

Example Code

`using System;
using System.Threading;
using SteamKit2;

class Program
{
    static SteamClient? steamClient;
    static CallbackManager? manager;
    static SteamUser? steamUser;
    static SteamApps? steamApps;

    static readonly string user = "";
    static readonly string pass = "";

    static bool isRunning = false;
    static int reconnectDelay = 1; 
    static readonly int maxReconnectDelay = 10;

    static void Main(string[] args)
    {
        var config = SteamConfiguration.Create(c =>
        {
            c.WithConnectionTimeout(TimeSpan.FromSeconds(30));
        });

        steamClient = new SteamClient(config);
        manager = new CallbackManager(steamClient);
        steamUser = steamClient.GetHandler<SteamUser>();
        steamApps = steamClient.GetHandler<SteamApps>();

        if (manager != null)
        {
            manager.Subscribe<SteamClient.ConnectedCallback>(OnConnected);
            manager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);
            manager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn);
            manager.Subscribe<SteamUser.LoggedOffCallback>(OnLoggedOff);
            manager.Subscribe<SteamApps.CDNAuthTokenCallback>(OnCDNAuthToken);
        }

        isRunning = true;

        Console.WriteLine("Connecting to Steam...");
        Connect();

        while (isRunning)
        {
            manager?.RunWaitCallbacks(TimeSpan.FromSeconds(1));
        }
    }

    static void Connect()
    {
        steamClient?.Connect();
    }

    static void OnConnected(SteamClient.ConnectedCallback callback)
    {
        Console.WriteLine("Connected to Steam! Logging in '{0}'...", user);

        steamUser?.LogOn(new SteamUser.LogOnDetails
        {
            Username = user,
            Password = pass,
        });

        reconnectDelay = 5;
    }

    static void OnDisconnected(SteamClient.DisconnectedCallback callback)
    {
        Console.WriteLine("Disconnected from Steam");

        if (isRunning)
        {
            Console.WriteLine($"Reconnecting in {reconnectDelay} seconds...");
            Thread.Sleep(TimeSpan.FromSeconds(reconnectDelay));

            Connect();

            reconnectDelay = Math.Min(reconnectDelay * 2, maxReconnectDelay);
        }
    }

    static void OnLoggedOn(SteamUser.LoggedOnCallback callback)
    {
        if (callback.Result != EResult.OK)
        {
            Console.WriteLine("Unable to logon to Steam: {0} / {1}", callback.Result, callback.ExtendedResult);

            if (callback.Result == EResult.AccountLogonDenied)
            {
                Console.WriteLine("This account is protected by Steam Guard. You need to provide the auth code sent to the associated email address.");
                isRunning = false;
                return;
            }

            isRunning = false;
            return;
        }

        Console.WriteLine("Successfully logged on!");

        GetCDNAuthToken();
    }

    static void OnLoggedOff(SteamUser.LoggedOffCallback callback)
    {
        Console.WriteLine("Logged off of Steam: {0}", callback.Result);
    }

    static void GetCDNAuthToken()
    {
        uint depotId = 1203221;
        string server = "dl.steam.clngaa.com";
        uint appId = 0;

        Console.WriteLine($"Requesting CDN Auth Token for Depot: {depotId}, Server: {server}, AppID: {appId}");
        steamApps?.GetCDNAuthToken(depotId, appId, server);
    }

    static void OnCDNAuthToken(SteamApps.CDNAuthTokenCallback callback)
    {
        if (callback.Result == EResult.OK)
        {
            Console.WriteLine($"Received CDN Auth Token: {callback.Token}");
            Console.WriteLine($"Token Expiration: {callback.Expiration}");
        }
        else
        {
            Console.WriteLine($"Failed to get CDN Auth Token. Result: {callback.Result}");
        }

        isRunning = false;
    }
}`

Additional Information

No response

xPaw commented 1 month ago

If you're getting no response then steam is not sending one. You can confirm that with some other message.

huddhudd commented 1 month ago

But Depot DownloaderMod works fine, it used to happen unexpectedly. Did something change