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

Temporary(?) connection problems #229

Closed JustArchi closed 7 years ago

JustArchi commented 8 years ago

SK2 issues is the first page I check when I notice some steam anomalies that shouldn't take place.

Since some hours all of my SK2-based projects have serious problems connecting with CMs, it takes at least dozen of reconnect attempts to finally connect to some CM.

This is probably temporary issue, so it should be closed as soon as everything is back to normal, but it's definitely not usual issue, as 99-100% of CMs are online, yet bots have some serious issues to connect. In fact, it's first time I see something like that myself, so perhaps it's also worth to investigate the root cause.

I'm posting it here so more people can see, and perhaps debug the problem or get more info. I hope you don't consider it as spam.

See also: https://github.com/JustArchi/ArchiSteamFarm/issues/65 https://www.reddit.com/r/SteamBot/comments/3zsht8/steambots_taking_forever_to_log_in/

Netshroud commented 8 years ago

Can you please provide DebugLog output with the "ServerList" category next time this happens?

xPaw commented 8 years ago

Yeah I noticed this yesterday too. Doing this on the the startup solves it: https://github.com/SteamRE/SteamKit/blob/master/Samples/7.ServerList/Program.cs#L106-L115

JustArchi commented 8 years ago

Thank you @xPaw.

Indeed, SteamDirectory.Initialize() solves the issue. Perhaps it's enough to just update SteamKit2 built-in CM list then?

I still find it weird that SK2 couldn't make a connection if ~99-100% of CMs were up.

azuisleet commented 8 years ago

I'm certain the majority of the bootstrap list is now out of date. I'm hesistant to OK a background job that calls GetCMList without also including persistent caching mechanisms.

Netshroud commented 8 years ago

@JustArchi: Likely ~99-100% of CMs were up, but SteamKit didn't know about them.

I don't think we should update the inbuilt list, I think we should remove it. steamclient has not had a built-in list for months and falls back to the Web API if there are no servers.

We'd need to be able to handle the case where there are 0 known servers (e.g. no network connection at all, nothing persisted). Currently I think we'd just die with an unhandled exception.

JustArchi commented 8 years ago

Yep, I think the same. It sounds good to ask Web API for list of CMs. Having built-in list serves little to no purpose, being unable to connect to web api most likely results also being unable to connect to steam, or even whole network, so it's not like there must be some fallback list in case web api doesn't return a result.

Up to you guys, personally I'd probably add something like a static list of CMs that api returned, called on first CMClient initialization, then using that list with all other CMClient initializations, unless developer specified otherwise. Asking web API for list of CMs on every new SteamClient() shouldn't be the case.

ghost commented 8 years ago

I tried running this sample program and only "Connecting to Steam..." followed by "Disconnected from Steam" was displayed on the console. Adding this before steamClient.Connect(); solved the problem:

var loadServersTask = SteamDirectory.Initialize();
loadServersTask.Wait();

if (loadServersTask.IsFaulted) {
    Console.WriteLine("Error loading server list from directory: {0}", loadServersTask.Exception.Message);
    return;
}
JustArchi commented 7 years ago

I noticed this issue is actually quite dated and was solved with Smart CM list rewrite, so I'm closing it as I no longer see a point of it. Feel free to re-open if needed.